unix is my ide
DESCRIPTION
TRANSCRIPT
Unix is my IDETomáš Kramár, @tkramar
Integrated Development EnvironmentThe primary rationale for using an IDE is that it gathers all your tools in the same place, and you can use them in concert with roughly the same user interface paradigm, and without having to exert too much effort to make separate applications cooperate.
Using UNIX as IDE● Shell tips● ZSH● Moving around● Terminal multiplexor● Composing commands● Customizing applications
Shell tips
#1 I need to run a long command I ran previouslyWrong:● lookup the parameters and type it all again● <up> <up> <up> ....● grep .bash_history
Good:● <c-r>, start typing, <c-r> to scroll results
#2 Oops, I made a typoWrong● <left> <left> <backspace> <backspace> ....Good● <c-u> - deletes from cursor to the beginning● <c-k> - deletes from cursor to the end● <c-w> - deletes word before cursor● <c-a> - move to the beginning● <c-e> - move to the endBetter● use vi-mode
#3 I need to switch to a different applicatione.g., I am in vim and want to try something in irb
Wrong:● open new terminal window
Good● <c-z> to suspend● fg to resume
#4 I need to disconnect from remote machineWrong● Ok, I'll wait
Good● <c-z> to suspend● bg to run in background● disown to ignore SIGHUP
#5 I forgot sudoWrong● <up> <c-a> sudo <cr>
Good● sudo !!● !! is alias for last command
Better● Custom keybinding that inserts sudo
#6 I want to change this file's extensionWrong● cp /opt/nginx/conf/nginx.conf
/opt/nginx/conf/nginx.conf.bak
Good● cp /opt/nginx/conf/nginx.conf{,.bak}
#7 I want to exit the shellWrong● type 'exit'● click close button
Good● <c-d>
Keybindings work everywhere (readline).● mysql● psql● irb● ..● even browser's textarea
ZSH
Features● Autocompletion menu● Autocomplete everything
○ command line parameters○ remote servers○ remote filesystems○ context-sensitive completion (e.g., dvips, git)○ kill
● Fuzzy autocompletion● Globbing
○ ls **/*.txt
Moving around
Stupid tricks● autocomplete● "cd" (no args) back to home● "cd -" back to previous directory
Use the dirstack● dirs -v● pushd/popd
Or
● setopt auto_pushd● cd +3
Ranger● https://github.com/hut/ranger● OSX Finder \w vim keybindings● Integrates with shell easily
Terminal multiplexor
tmux● multiplexes several virtual terminals● sessions/windows● tile management
Composing commands
How do you identify your largest files?
How do you identify your largest files?
wc -l **/*.rb | tac | tail -n +2 | sort -n -r | head -10
Customizing applications
Embrace aliasesalias grep="grep --color=auto"alias lsa="ls -AahXBFov --color=auto --indicator-style=file-type --group-directories-first"
alias pacman="sudo pacman"
Application level aliases● git la
dotfiles● Most applications are configurable in plain
text○ .vimrc, .zshrc, .ranger, .rvm, .ssh ...○ Transfer between machines, backup, restore
Resources● http://dotfiles.github.com/● https://github.com/kremso/dotfiles
● https://github.com/robbyrussell/oh-my-zsh