Shell (Bash/Zsh)
POSIX shell such as Bash & Zsh.
Table of Contents
Refer
Shell uses emacs like keymaps by default.
Keymaps
Bare essentials
Move back one character
Ctrl-b
Move forward one character
Ctrl-f
Delete the character underneath the cursor
Ctrl-d
Undo the last editing command ()can undo till an empty line)
Ctrl-_ or C-x C-u
Movement
Move to the start of the line
Ctrl-a
Move to the end of the line
Ctrl-e
Move forward a word
Meta-f
Move backward a word
Meta-b
Clear the screen
Ctrl-l
Kill and yank
Kill text from cursor position to EOL (end of line)
Ctrl-k
Kill from cursor to the end of the current word
M-d
Kill from cursor start of word or if between words then prev. word
M-[DEL]
Kill from the cursor to the previous whitespace
Ctrl-w
Yank latest killed text back into the buffer at cursor
Ctrl-y
Rotate the kill-ring, and yank the new top
M-y
Bashrc
Change default shell
# overwrite default shell to use zsh
my_shell=$(which zsh)
SHELL=$my_shell exec $my_shell
man console_codes
# useful notes
\e = \033 -> octal, ESC (0x1B, ^[), starts an escape sequence;
\a = \007 -> octal, BEL, xterm(1) accepts a BEL to end an OSC string.
Command execution time
_start=$(date +%s);
sleep 3;
_end=$(date +%s); _diff=$(( $_end - $_start)); echo "tm diff: $_diff"