Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Terminal Tips and Tricks

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Terminal Tips and Tricks

Avatar for Eugene Oskin

Eugene Oskin

January 20, 2018
Tweet

More Decks by Eugene Oskin

Other Decks in Programming

Transcript

  1. Wikipedia A terminal emulator, terminal application, term, or tty for

    short, is a program that emulates a video terminal within some other display architecture. Though typically synonymous with a shell or text terminal, the term terminal covers all remote terminals, including graphical interfaces. A terminal emulator inside a graphical user interface is often called a terminal window.
  2. Beginning • Ask for help • Usage syntax • Git

    commands • Environment variables • Tune you terminal
  3. Ask for help Most of the commands accept an argument

    --help or -h and print help message. But also there is man command and help. My advice: use tldr
  4. Git command • Add chunks git add -p • Commit

    chunks git commit -p • Interactive rebase git rebase -i • Create alias git config --global alias.cc commit • Create your own:
  5. Most know commands • List current directory content: ls [file

    ...] • Change current directory: cd <path to dir> • Move file: mv <old_place> <new_place> • Copy file: cp <old_place> <new_place> • List file content: cat • Editor: nano, vi, vim, emacs • Package managers: brew, apt, apt-get, yum
  6. Level up (advanced) • Hotkeys • Aliases: alias, unalias •

    std{in,out,err} redirections • Pipes • shellcheck • Functions
  7. Hotkeys • Undo: C-_ • Reverse-search history: C-r • Jump

    to start of line: C-a • Jump to end of line: C-e • Jump word: Meta-<arrow-left/arrow-right> • List all hotkey: ◦ bash: bind -p ◦ zsh: bindkey
  8. std{in,out,err} redirects • Use < filename to pass file content

    as stdin. • Use > filename to redirect stdout. • Use 2> filename to redirect stderr. • Use 2>&1 to forward stderr to stdout. • • Use <<<"string" to pass string as stdin. • Use heredoc format:
  9. Pipes Pipe redirect left command stdout to right command stdin

    Use stderr redirection to pipe stderr too The base use with sed and awk
  10. Functions Set flag -e to fail on errors: set -e

    Use && and || to handle errors
  11. Scripting Use smartcd to run script on entering to a

    directory. Use composure to store your functions and snippets.