-
-
Save felipepodesta/068ad5cddbbc6370802e55287423f843 to your computer and use it in GitHub Desktop.
bash/zsh help functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
help-history() { | |
echo -e " | |
List of Event Designators (zshexpn) | |
=================================== | |
!$ last word | |
!! last line | |
!:0 first word from previous command | |
!:0-2 first three words | |
!!:s^foo^bar^ | |
^foo^bar replace on previous command | |
^foo^bar:G greedy replace | |
!0 first command-line | |
!-1 previous | |
!{str} | |
!str most recent line starting with 'str' | |
!?str containing 'str' | |
!# current command line | |
!#1 current command line, second parameter | |
" | |
} | |
help-variable() { | |
echo -e " | |
List of parameter expansion (zshexpn) | |
===================================== | |
\${name} | |
\${name-word} word unless name is set | |
\${name+word} word if name is set | |
\${name=word} name is set to word if unset | |
... | |
\${name#pattern} pattern matches beginning of name, remove match | |
\${name%pattern} pattern matches end of name, remove match | |
\${i:s/foo/bar/} | |
\$var[(w)1] split variable by word not char | |
Examples: | |
\${\${(s.:.)f}[1]} split \$j by : and return first field | |
\${(j.:.)\${(s.:.)f}[2,3]} split \$j by : and join second and third field by : | |
" | |
} | |
help-keys-long() { | |
echo -e " | |
Cutting & Pasting | |
=================== | |
cp termine.rdf /tmp/ | |
^ | |
ctrl-u /tmp/ | |
ctrl-w cp /tmp/ | |
ctrl-k cp termine.rdf | |
ctrl-t cp termine.rd f/tmp/ # move a letter arround | |
ctrl-y insert last delete | |
ctrl-k kill text to right of cursor. This is the bash equiv. of cut | |
ctrl-K This command deletes from the cursor to the end of the line. | |
ctrl-y yank text. This is the bash equiv. of paste | |
ctrl-d delete | |
Esc-Del Delete word to the left of the cursor | |
History | |
======== | |
ctrl-r reverse search (semi-interactive) | |
ctrl-n next history | |
ctrl-p prev history | |
ctrl-o switch and execute last two commands (?) | |
ctrl-O exec command an reuse | |
Movement | |
========= | |
ctrl-x x jump to beginning of line / jump back | |
ctrl-p previous command. This is the same as the up arrow | |
ctrl-n next charachter. self explanitory | |
ctrl-b left one charachter aka back or left arrow | |
ctrl-f forward one charachter or right arrow | |
ctrl-a beginning of line. this is also useful in long commands if you just want to change the first part | |
Esc-b Move cursor to the beginning of the word to the left | |
Esc-f Move cursor to the beginning of the word to the right | |
Misc | |
========= | |
ctrl-v next control key is shown in cmdline (usefull for bind) | |
ctrl-s suspend output (turn behaviour off with stty -ixon -ixoff) | |
ctrl-q resume output | |
ctrl-z suspend running process (fg to continue, fg %2 for previously suspended) | |
ctrl-d exit from shell by sending EOF | |
ctrz-c terminate process by sending SIGINT | |
" | |
} | |
# command line editing keys | |
help-keys() { | |
echo -e " | |
alt-b word backward | |
alt-f word forward | |
alt-h help on current command? | |
esc-backspace delete word | |
esc-q kill line, restore after next command | |
esc-t transpose words | |
ctrl-a jump to beginning of line | |
ctrl-b backward char | |
ctrl-d delete char | |
ctrl-e jump to end of line | |
ctrl-f forward char | |
ctrl-k kill to eol | |
ctrl-n history next | |
ctrl-o in history, execute command, bring up next | |
ctrl-p history prev | |
ctrl-r search history | |
ctrl-s forward search? | |
ctrl-w kill last word | |
ctrl-x jump start, again jump back? | |
ctrl-y yank copied text | |
" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment