Below is a list of my favorite (hard to remember) bash shortcats and tricks I like to use.
Ctrl + w Cut the Word before the cursor to the clipboard
Ctrl + y Paste the last thing to be cut (yank)
Alt + r Cancel the changes and put back the line as it was in the history (revert).
- How to copy the last command
- How to copy and paste the last command output
# readline function
shell-expand-line (M-C-e)
Example 1:
$ myvar="/etc/passwd"
$ echo $myvar
$ ls $(echo $myvar)
Before you press enter press now (M-C-e) and the line will turn into
ls /etc/passwd-rrr
Example 2:
$ ls -l /etc/passwd
$ echo !!
echo ls -l /etc/passwd
Example 3:
$ ls -l /etc/passwd
$ echo $(!!)
echo -rw-r--r-- 1 root root 1399 May 17 02:19 /etc/passwd
References
http://ss64.com/bash/syntax-keyboard.html
http://superuser.com/questions/304519/how-to-copy-the-results-from-a-grep-command-to-the-bash-clipboard
http://superuser.com/questions/421463/why-does-ctrl-v-notpaste-in-bash-linux-shell
http://unix.stackexchange.com/questions/15850/how-to-use-keyboard-instead-of-mouse-middle-click-for-copy-paste
http://stackoverflow.com/questions/749544/pipe-to-from-clipboard
https://wiki.archlinux.org/index.php/Keyboard_Shortcuts
http://rtomaszewski.blogspot.co.uk/2013/06/linux-and-bash-cheat-sheet.html
No comments:
Post a Comment