Skip to content

Instantly share code, notes, and snippets.

@davidxia
Created September 6, 2012 21:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidxia/3660576 to your computer and use it in GitHub Desktop.
Save davidxia/3660576 to your computer and use it in GitHub Desktop.
NYC Lunch and Learn - September 7, 2012 - Neville Li & David Xia

NYC Lunch and Learn

September 7, 2012

Neville Li & David Xia

Use Command Line Shortcuts

Basic

  • clear the screen Ctrl-L
  • signal end of file (close terminal tab or exit ssh) Ctrl-D
  • abort current command Ctrl-C

Navigation - I cry everytime I see you use arrow keys

  • jump to beginning of line Ctrl-A
  • jump to end of line Ctrl-E

Typing - stop holding down delete and waiting foreever

  • clear the line Ctrl-U
  • clear the line ahead of the cursor Ctrl-K
  • delete backwards one word Ctrl-W

Search Command History - you don't need to remember the exact command

  • search backwards Ctrl-R

  • search forwards Ctrl-S

  • more

Customize Your Prompt

  • PS1="[\d \t \u@\h:\w ] $ " displays date/time, hostname and current directory
  • add to ~/.bashrc to make permanent
  • more special characters

Complete Commands in Bash

Fast File Navigation - stop wasting your life on cd

  • autojump (homebrew/debian/ubuntu)
  • $ j [a few characters in the path]

Try Zsh - no one man should have all those z-shells ♫

  • zsh
  • oh-my-zsh
  • community-driven framework for managing zsh configuration
  • plugins
  • terminal themes
  • easily customizable

SSH Can Do That?

  • multiple connections
  • repeated connections
  • hostname aliases
  • don't need to type usernames
  • persistent connections
  • jumphost
  • more
@nevillelyh
Copy link

CTRL-P/N previous/next history entry
ALT-B/F back/forward one word

@nevillelyh
Copy link

@davidpoblador
Copy link

@nferch
Copy link

nferch commented Sep 7, 2012

If you elect to keep your dotfiles in git, you can use the following alias stolen from Pierre to prevent your home directory from being a giant git repo:

alias dotgit="GIT_DIR=$HOME/dotfiles.git GIT_WORK_TREE=$HOME git"

@nevillelyh
Copy link

@nevillelyh
Copy link

If you use iTerm2, in Preferences -> Profiles -> Keys
Left option key acts as: +Esc (default was normal)
This works with alt-b/f for backward/forward one word.

@nevillelyh
Copy link

Git:
~/.gitconfig init.templatedir for global template, located in .dotfiles/git
2 hooks: commit-msg for Gerrit and ctags index rebuild after repo changes.

git add -p # stage changes one by one
git diff --cached # show staged changes
git diff HEADn # diff against n'th previous change
git rebase -i HEAD
n # rebase from n'th previous change

Checkout https://github.com/nevillelyh/dotfiles/tree/master/.dotfiles/scripts/
git-amend # amend stage changes to current HEAD, reuse commit message, useful for revising review
git-review # gerrit review

Bootstrapping, one script to rule them all:
https://github.com/nevillelyh/dotfiles/blob/master/.dotfiles/scripts/bootstrap-dotfiles.sh

To move in to a new machine (homebrew style):
bash -c "$(curl -fsSL https://raw.github.com/nevillelyh/dotfiles/master/.dotfiles/scripts/bootstrap-dotfiles.sh)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment