2015-01-20 00:00:13 -08:00
|
|
|
alias q=exit
|
|
|
|
alias clr=clear
|
|
|
|
alias sudo='sudo '
|
|
|
|
|
2015-11-06 21:17:01 -08:00
|
|
|
alias ..="cd .."
|
|
|
|
alias ...="cd ../.."
|
|
|
|
alias ....="cd ../../.."
|
|
|
|
|
2015-01-20 00:00:13 -08:00
|
|
|
# Tools
|
2014-09-20 13:38:40 -07:00
|
|
|
alias ag='nocorrect noglob ag'
|
2015-06-18 13:16:54 -07:00
|
|
|
alias l="ls -l"
|
2015-06-19 07:04:48 -07:00
|
|
|
alias ll="ls -1"
|
|
|
|
alias la="ls -la"
|
2015-06-18 13:16:54 -07:00
|
|
|
alias ln="ln -v" # Verbose ln
|
2015-01-20 00:00:13 -08:00
|
|
|
alias wget='wget -c' # Resume dl if possible
|
|
|
|
alias rsyncd='rsync -va --delete' # Hard sync two directories
|
2015-09-10 22:44:27 -07:00
|
|
|
alias mkdir='mkdir -p'
|
2015-10-25 21:42:43 -07:00
|
|
|
alias gurl='curl --compressed'
|
2015-12-08 22:12:30 -08:00
|
|
|
zman() { PAGER="less -g -s '+/^ "$1"'" man zshall; }
|
|
|
|
take() { mkdir "$1" && cd "$1"; }
|
|
|
|
compdef take=mkdir
|
2015-10-25 21:42:43 -07:00
|
|
|
|
|
|
|
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
|
|
|
|
alias localip="ipconfig getifaddr en0"
|
|
|
|
alias ips="ifconfig -a | grep -o 'inet6\? \(\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)\|[a-fA-F0-9:]\+\)' | sed -e 's/inet6* //'"
|
|
|
|
|
|
|
|
# View HTTP traffic
|
|
|
|
alias sniff="sudo ngrep -d 'en0' -t '^(GET|POST) ' 'tcp and port 80'"
|
|
|
|
alias httpdump="sudo tcpdump -i en0 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""
|
|
|
|
# URL-encode strings
|
|
|
|
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
|
|
|
|
# Make URL REQUEST shortcuts
|
|
|
|
for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
|
|
|
|
alias "$method"="lwp-request -m '$method'"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Send to sprunge.us
|
|
|
|
alias bin="curl -s -F 'sprunge=<-' http://sprunge.us | head -n 1 | tr -d '\r\n ' | pbcopy"
|
2014-09-05 13:55:50 -07:00
|
|
|
|
2015-06-19 07:04:48 -07:00
|
|
|
j() {
|
2015-10-25 21:42:43 -07:00
|
|
|
local fasd_ret="$(fasd -i -d "$@")"
|
|
|
|
[[ -d "$fasd_ret" ]] && cd "$fasd_ret" || print "$fasd_ret"
|
2015-06-19 07:04:48 -07:00
|
|
|
}
|
|
|
|
|
2015-01-20 00:00:13 -08:00
|
|
|
# transmission-remote
|
|
|
|
if is-callable 'transmission-remote'; then
|
|
|
|
alias bt='transmission-remote server'
|
2015-08-19 18:23:35 -07:00
|
|
|
alias bt-clear='bt -t all -r'
|
2015-01-20 00:00:13 -08:00
|
|
|
|
|
|
|
# pretty print torrent list on remote server
|
2015-05-20 19:53:27 -07:00
|
|
|
btl() {
|
2015-10-28 14:21:19 -07:00
|
|
|
local results=`transmission-remote server -l | \
|
2015-01-20 00:00:13 -08:00
|
|
|
awk 'NR > 1 { s = ""; for (i = 10; i <= NF; i++) s = s $i " "; print $9 " | " s }' | \
|
|
|
|
sed '$d' | \
|
|
|
|
perl -pe 's/\s\[[a-zA-Z0-9]+\]\s/ /g'`
|
2014-10-09 15:31:34 -07:00
|
|
|
|
2015-10-28 14:21:19 -07:00
|
|
|
[ -z "$results" ] && echo "No torrents!" || echo "$results"
|
2015-01-20 00:00:13 -08:00
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Editors
|
2015-10-04 19:29:29 -07:00
|
|
|
is-callable 'nvim' && alias vim='nvim'
|
2015-06-19 07:04:48 -07:00
|
|
|
v() { vim ${@:-.}; } # Open in vim
|
2015-11-23 12:26:55 -08:00
|
|
|
e() { # Open in emacs (daemon)
|
2015-11-27 19:58:09 -08:00
|
|
|
if pgrep Emacs 2>&1 >/dev/null; then
|
2015-11-23 12:26:55 -08:00
|
|
|
emacsclient -n ${@:-.};
|
|
|
|
else
|
|
|
|
/Applications/Emacs.app/Contents/MacOS/Emacs ${@:-.} &
|
|
|
|
fi
|
|
|
|
}
|
2015-04-22 17:46:04 -07:00
|
|
|
ee() { # emacs in project root
|
2015-10-28 14:21:19 -07:00
|
|
|
git root 2>/dev/null && e "$(git rev-parse --show-toplevel)" || e .
|
2015-04-22 17:46:04 -07:00
|
|
|
}
|
2015-12-04 00:30:21 -08:00
|
|
|
ediff() {
|
|
|
|
e --eval "(ediff-files \"$1\" \"$2\")"
|
|
|
|
}
|
2015-01-20 00:00:13 -08:00
|
|
|
|
2015-07-26 04:18:32 -07:00
|
|
|
# Compilers, interpretors 'n builders
|
2015-01-20 00:00:13 -08:00
|
|
|
alias va='vagrant'
|
|
|
|
alias py='python'
|
|
|
|
alias pye='pyenv'
|
|
|
|
alias rb='ruby'
|
|
|
|
alias rbe='rbenv'
|
|
|
|
alias b='bundle'
|
|
|
|
alias be='bundle exec'
|
|
|
|
alias bi='bundle install -path vendor'
|
2015-07-26 04:18:32 -07:00
|
|
|
alias ans='ansible'
|
|
|
|
alias ansp='ansible-playbook'
|
|
|
|
alias fabg='noglob fab -f ~/.dotfiles/ansible/fabfile.py'
|
2015-02-01 23:02:40 -08:00
|
|
|
alias rk='noglob rake'
|
|
|
|
alias rkg='noglob rake -g'
|
|
|
|
alias m='make'
|
2015-09-26 13:46:58 -07:00
|
|
|
alias c11='clang++ -std=c++11'
|
|
|
|
alias dk='docker'
|
2015-11-25 14:28:41 -08:00
|
|
|
alias exe='exercism'
|
2015-07-30 08:57:22 -07:00
|
|
|
|
2015-01-20 00:00:13 -08:00
|
|
|
# GIT
|
|
|
|
is-callable 'hub' && alias git='hub'
|
|
|
|
g() { [ $# -eq 0 ] && git status --short || git $* }
|
2015-12-08 22:12:30 -08:00
|
|
|
compdef _git g=git
|
2015-01-20 00:00:13 -08:00
|
|
|
|
|
|
|
alias gi='git init'
|
|
|
|
alias gs='git status'
|
2015-06-19 07:04:48 -07:00
|
|
|
alias gsu='git submodule'
|
2015-01-20 00:00:13 -08:00
|
|
|
alias gco='git checkout'
|
|
|
|
alias gc='git commit'
|
|
|
|
alias gcm='noglob git commit -m'
|
2015-07-29 03:39:34 -07:00
|
|
|
alias gcma='noglob git commit --amend -m'
|
2015-01-21 12:16:01 -08:00
|
|
|
alias gd='git diff'
|
2015-01-20 00:00:13 -08:00
|
|
|
alias gp='git push'
|
2015-08-28 18:16:12 -07:00
|
|
|
alias gpl='git pull'
|
2015-01-20 00:00:13 -08:00
|
|
|
alias ga='git add'
|
2015-04-22 20:53:37 -07:00
|
|
|
alias ge='git exec'
|
2015-01-20 00:00:13 -08:00
|
|
|
alias gb='git branch'
|
|
|
|
alias gap='git add --patch'
|
|
|
|
alias gr='git reset "HEAD^"'
|
2015-06-19 07:04:48 -07:00
|
|
|
alias gre='git remote'
|
2015-01-20 00:00:13 -08:00
|
|
|
|
|
|
|
# Tmux
|
|
|
|
if is-callable 'tmux'; then
|
|
|
|
alias t='tmux'
|
|
|
|
alias ts='tmux send-keys'
|
2015-10-02 22:16:21 -07:00
|
|
|
alias tl='tmux list-sessions'
|
2015-09-30 09:26:01 -07:00
|
|
|
alias ta='tmux attach'
|
2015-01-20 00:00:13 -08:00
|
|
|
|
2015-10-02 22:16:21 -07:00
|
|
|
if [ -n $TMUX ]; then
|
|
|
|
# Detach all other clients to this session
|
|
|
|
alias takeover='tmux detach -a'
|
|
|
|
fi
|
2015-09-30 09:26:01 -07:00
|
|
|
|
|
|
|
# Start new session or create a grouped session so I'm not simply watching
|
|
|
|
# the same session in both windows.
|
2015-10-02 22:16:21 -07:00
|
|
|
tdup() {tmux new-session -t $1}
|
2015-01-20 00:00:13 -08:00
|
|
|
fi
|
2015-06-19 07:04:48 -07:00
|
|
|
|
|
|
|
if is-mac; then
|
|
|
|
alias ls="ls -G"
|
|
|
|
|
|
|
|
alias c11='clang++ -std=c++11 -stdlib=libc++'
|
|
|
|
alias eclimd='/Applications/eclipse/eclimd'
|
|
|
|
|
|
|
|
# Homebrew
|
|
|
|
alias br='brew'
|
|
|
|
alias bru='brew update && brew upgrade --all'
|
|
|
|
alias brc='brew cask'
|
|
|
|
alias codekit='open -a CodeKit'
|
|
|
|
elif is-cygwin; then
|
2015-07-29 03:39:34 -07:00
|
|
|
alias open='cygstart'
|
2015-06-19 07:04:48 -07:00
|
|
|
alias pbcopy='tee > /dev/clipboard'
|
|
|
|
alias pbpaste='cat /dev/clipboard'
|
|
|
|
else
|
2015-07-29 03:39:34 -07:00
|
|
|
alias open='xdg-open'
|
2015-06-19 07:04:48 -07:00
|
|
|
alias ls="ls --color=auto"
|
|
|
|
|
|
|
|
if (( $+commands[xclip] )); then
|
|
|
|
alias pbcopy='xclip -selection clipboard -in'
|
|
|
|
alias pbpaste='xclip -selection clipboard -out'
|
|
|
|
elif (( $+commands[xsel] )); then
|
|
|
|
alias pbcopy='xsel --clipboard --input'
|
|
|
|
alias pbpaste='xsel --clipboard --output'
|
|
|
|
fi
|
|
|
|
fi
|
2015-10-28 14:21:33 -07:00
|
|
|
alias c='pbcopy'
|
|
|
|
alias p='pbpaste'
|
2015-07-29 03:39:34 -07:00
|
|
|
|
|
|
|
# By default, open cwd
|
|
|
|
o() { open ${@:-.}; }
|
2015-12-08 22:12:30 -08:00
|
|
|
compdef o=open
|