Tag Archives: terminal

Mac OS X command-line bash keyboard shortcuts

Recently found out list of useful keyboard shortcuts for bash at Mac OS X.

There is a list of the bash default keyboard editting shortcuts configured on a Mac OS X.

CTRL+a – move cursor to beginning of the line. (I think of this as anchoring my cursor to the start.);
CTRL+e – move cursor to the end of the line;
CTRL+k – delete everything from under the cursor to the end of the line. (I think of this as killing the rest of my line.);
CTRL+f – move forward one character. Identical to →;
CTRL+b – move backward one character. Identical to ←;
ESC+f – move forward one word;
ESC+b – move backward one word;
CTRL+u – delete everything from under the cursor the beginning of the line;
CTRL+w – delete from under the cursor to the beginning of the word;
CTRL+r – recall previous commands by searching for them;
CTRL+t – transpose (swap) the two characters before the cursor with one another;
ESC+t – transpose (swap) the two words before the cursor with one another;
CTRL+y – paste the most previously-deleted string. Basically a sort of command-line editting “undo”;
CTRL+z – stop the current process and send it to the background;
CTRL+c – send an SIG_HUP to the current process. The net effect of doing this on the command line is that you cancel your current command and are presented with a blank new line;
CTRL+d – send an end-of-file special character to the current process. Doing this at the command line is identical to closing your terminal window;
CTRL+p – recall previous command executed. Identical to ↑;
CTRL+d – forward delete;
CTRL+h – backspace;
CTRL+j – carriage return. Identical to hitting the return key;
CTRL+m – newline. Identical to return;
CTRL+l – repaint screen. This is useful if a program’s output is overwriting some text on your terminal. The effect of doing this on a command line is that you clear the screen. Note than in Apple’s Terminal.app, you can also press +K to clear the screen;
CTRL-x + CTRL-x – mark current location in line and jump to beginning of line or second mark if defined. Repeat to jump to between both marks;
ESC+c – capitolize word under cursor and move to next word;
ESC+u – uppercase word under cursor and move to next word;
ESC+l – lowercase word under cursor and move to next word;
ESC+. – insert last word from previous command after cursor;
TAB – Auto-completes file, folder, and program names;
ESC-? – list the possible completions;
CTRL-x / – list the possible filename completions;
ESC-/ – attempt filename completion;
CTRL-x ~ – list the possible variable completions;
ESC- ~ – attempt username completion;
CTRL-x $ – list the possible variable completions;
ESC-$ – attempt variable completion;
CTRL-x @ – list the possible hostname completion;
ESC-@ – attempt hostname completion;
CTRL-x ! – list the possible command completions;
ESC-! – attempt command completion;
ESC-TAB – attempt completion from previous commands in the history list;

Enjoy.

Tmux cheat sheet

It’s just several lines of tmux commands to not to forget and start googling again;)

tmux is a terminal multiplexer: it enables a number of terminals (or windows), each running a separate program, to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.

tmux attach || tmux new — attaches to existing server process or creates new if it does not exist.

When you are in tmux terminal window you can use next commands to manage your session:

Ctrl+b d — to exit.

Ctrl+b c — to create new window;

Ctrl+b 0…9 — to switch to window number;

Ctrl+b p — to switch to previous window;

Ctrl+b n — to switch to next window;

Ctrl+b l — to switch to previous active window (from which you switched to current);

Ctrl+b & — to close window (you can also type exit).

In one window you can have several panels:
Ctrl+b % — to split current window to 2 panels vertically;
Ctrl+b “ — to split current window to 2 panels horizontally;
Ctrl+b →←↑↓ — to switch between panels;
Ctrl+b x — to close panel (or you can do this by typing exit).

Hope this will help someone.