BASH Shortcuts I was not not aware of

New Shortcuts:

  • CTRL+A Move cursor to start of the current line ( mnemnoic: Anfang)
  • CTRL+K Delete from cursor to end of line ( mnemnoic: reverse of CTRL+U )
  • CTRL+Y Apparently bash has a cut-register ( like vim ): paste from cut-register

Bash ! commands:

After running the following command:

$ ls -lah data
total 0
drwxr-xr-x   4 kiru  staff   136B Mar 18 21:12 .
drwxr-xr-x  43 kiru  staff   1.4K Jul 15 23:13 ..
drwxr-xr-x  13 kiru  staff   442B May 27 16:10 archive
drwxr-xr-x   2 kiru  staff    68B Mar 18 21:12 upload
$
$ !! # releat last command
total 0
drwxr-xr-x   4 kiru  staff   136B Mar 18 21:12 .
drwxr-xr-x  43 kiru  staff   1.4K Jul 15 23:13 ..
drwxr-xr-x  13 kiru  staff   442B May 27 16:10 archive
drwxr-xr-x   2 kiru  staff    68B Mar 18 21:12 upload

!$ last word of previous command ( menmonic: $ in vi jumps to the end of line, so this will give me the ‘end’ of command)

$ !$
data
-bash: data: command not found

!$:p print last word of command:

$ !$:p
data

!* or !*:p second previous switch ( when is this useful?)

$ !*
-lah data
-bash: -lah: command not found