Ctrl-a Jump to the start of the line Ctrl-e Jump to the end of the line Ctrl-k Remove everything between cursor and end of line (K is for KILL) Ctrl-u Remove everything between cursor and start of line Ctrl-w Remove word backwards Alt-d Remove word forwards Ctrl-y Paste the last thing you removed with Ctrl-K or Ctrl-W or Ctrl-U (Y is for YANK) Ctrl-l Same as 'clear' Ctrl-d Same as 'exit' Ctrl-d If text in command, same as DELETE Ctrl-h If text in command, same as BACKSPACE Ctrl-x-e Open up in-terminal editor (emacs / vim) and write multi line command. Exiting the editor will then execute the command Ctrl-p Cycle through previous commands. Same as arrow up key Ctrl-N When cycling through previous commands, go to next command. Same arrow down key
!$ Bang-Dollar. Wildcard for the last argument of the previous command Esc-. Will return the last argument of the previous command Esc could be Alt in other systems Esc-Bksp Remove everything between special character (_./) and cursor Esc-F Move forward one word in the command line Esc-B Move backwards one word in the command line
See Corey Schafer video on YouTube The prompt is determined by the PS1 variable
PS1="-> " Sets the prompt literally to -> PS1="\u@\h \W -> " username@hostname currentdir ->
\h hostname up to the first . \n newline \s the name of the shell \t the current time in 24 hour format \u username of the current user \w current working directory - full absolute path \W the basename of the current working directory - only current directory \D timestamp, e.g. \D{%H:%M:%S} will display hour:minute:second
The custom PS1 variable typically gets very long, so you may want to break it up in several pieces, so its more human understandable Has added benefit that you can describe the different parts with comments.
PS1="$(tput setaf 166)\u" # orange user PS1+="$(tput setaf 228)@\h" # yellow host PS1+="$(tput setaf 71)\W -> " # green directory PS1+="$(tput sgr0)" # reset formatting so colors do not bleed into command line
You should also envelope the tput commands with [ and ], i.e. [$(tput setaf 166)] to prevent the cursor from acting up in the terminal export PS1