Clean up zsh/bash rcfiles

This commit is contained in:
Henrik Lissner 2015-01-20 03:00:13 -05:00
parent c216de9b26
commit c61b2167d6
9 changed files with 128 additions and 117 deletions

View file

@ -3,6 +3,11 @@
alias q='exit' alias q='exit'
alias clr='clear' alias clr='clear'
alias catn='cat -n' # cat + line numbers alias catn='cat -n' # cat + line numbers
# Allow sudo with aliases
alias sudo='sudo '
alias ls='ls -G'
alias l='ls -o'
alias la='ls -AGFoh'
# Command fixes # Command fixes
alias ln="${aliases[ln]:-ln} -v" # verbose ln alias ln="${aliases[ln]:-ln} -v" # verbose ln
@ -10,8 +15,8 @@ alias wget='wget -c' # Resume download if possible
alias rsyncd='rsync -va --delete' # Hard sync two directories alias rsyncd='rsync -va --delete' # Hard sync two directories
# Shortcut for git # Shortcut for git
alias g=git is-callable hub && alias git='hub'
is-callable 'hub' && alias git='hub' g() { [ $# -eq 0 ] && git status --short || git $* }
alias gi='git init' alias gi='git init'
alias ga='git add' alias ga='git add'
@ -45,51 +50,6 @@ if is-callable 'tmux'; then
alias tn='tmux new-session -t "x"' alias tn='tmux new-session -t "x"'
fi fi
# OS-specific aliases
if [[ "$OSTYPE" == darwin* ]]; then
alias codekit='open -a CodeKit'
alias br='brew'
alias bru='brew update && brew upgrade'
function v {
[ $# -eq 0 ] && vim . || vim $@
}
unalias e # get rid of prezto's alias
function e {
[ -z "$@" ] && input="." || input=$@
emacsclient -n $input
}
function et {
[ -z "$@" ] && input="." || input=$@
emacsclient -nw $input
}
alias c11='clang++ -std=c++11 -stdlib=libc++'
alias eclimd='/Applications/eclipse/eclimd'
else
alias ipt='sudo iptables'
fi
# transmission-remote
if is-callable 'transmission-remote'; then
alias bt='transmission-remote server'
# pretty print torrent list on remote server
function btl {
results=`transmission-remote server -l | \
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'`
if [ -z "$results" ]; then
echo "No torrents!"
else
echo $results
fi
}
fi
alias va='vagrant' alias va='vagrant'
alias rk='rake' alias rk='rake'
alias rkg='rake -g' alias rkg='rake -g'
@ -104,13 +64,3 @@ alias bi='bundle install --path vendor'
alias py='python' alias py='python'
alias pye='pyenv' alias pye='pyenv'
alias pyi='ipython' alias pyi='ipython'
# Bash-only aliases
if [ -z "$ZSH_VERSION" ]; then
# Allow sudo with aliases
alias sudo='sudo '
alias ls='ls -G'
alias l='ls -o'
alias la='ls -AGFoh'
fi

View file

@ -1,3 +0,0 @@
# Executes commands at logout.
echo "Logged out!"

View file

@ -1,7 +1,7 @@
# Executes commands at login pre-zshrc. # Executes commands at login pre-zshrc.
# Browser # Browser
[[ "$OSTYPE" == darwin* ]] && export BROWSER='open' export BROWSER='open'
## Editors ## Editors
export EDITOR='vim' export EDITOR='vim'
@ -19,30 +19,6 @@ if (( $+commands[lesspipe] )); then
export LESSOPEN='| /usr/bin/env lesspipe %s 2>&-' export LESSOPEN='| /usr/bin/env lesspipe %s 2>&-'
fi fi
## Language
if [[ -z "$LANG" ]]; then
export LANG='en_US.UTF-8'
fi
## Paths
# Ensure path arrays do not contain duplicates.
typeset -gU cdpath fpath mailpath path
# Set the list of directories that Zsh searches for programs.
path=(
$HOME/.{py,rb}env/bin
$HOME/.dotfiles/bin
/usr/local/{bin,sbin}
/usr/{bin,sbin}
/{bin,sbin}
)
[[ "$OSTYPE" == darwin* ]] && path+="/usr/X11/bin"
fpath=(
$HOME/.zsh/functions
$fpath
)
# Temporary Files # Temporary Files
if [[ ! -d "$TMPDIR" ]]; then if [[ ! -d "$TMPDIR" ]]; then
export TMPDIR="/tmp/$USER" export TMPDIR="/tmp/$USER"
@ -51,3 +27,24 @@ fi
TMPPREFIX="${TMPDIR%/}/zsh" TMPPREFIX="${TMPDIR%/}/zsh"
[[ ! -d "$TMPPREFIX" ]] && mkdir -p "$TMPPREFIX" [[ ! -d "$TMPPREFIX" ]] && mkdir -p "$TMPPREFIX"
## Language
[[ -z "$LANG" ]] && export LANG='en_US.UTF-8'
## Paths
# Ensure path arrays do not contain duplicates.
typeset -gU cdpath fpath mailpath path
# Set the list of directories that Zsh searches for programs.
path=(
$HOME/.dotfiles/bin
/usr/local/{bin,sbin}
/usr/{bin,sbin}
/{bin,sbin}
)
fpath=(
$HOME/.zsh/prompts
$HOME/.zsh/completion
$fpath
)

View file

@ -1,16 +1,93 @@
#!/bin/zsh #!/bin/zsh
# ZSH-specific aliases. Find the rest in ~/.bash/aliases
source ~/.bash/aliases
# GIT
alias ag='nocorrect noglob ag'
alias rk='noglob rake'
alias rkg='noglob rake -g'
alias rename='noglob rename'
export p=~/Dropbox/projects export p=~/Dropbox/projects
zman() { alias q=exit
PAGER="less -g -s '+/^ "$1"'" man zshall alias clr=clear
alias sudo='sudo '
# Homebrew
alias br='brew'
alias bru='brew update'
# Tools
alias codekit='open -a CodeKit'
alias ag='nocorrect noglob ag'
alias rk='noglob rake'
alias rkg='noglob rake -g'
alias ln="${aliases[ln]:-ln} -v" # Verbose ln
alias wget='wget -c' # Resume dl if possible
alias rsyncd='rsync -va --delete' # Hard sync two directories
zman() { PAGER="less -g -s '+/^ "$1"'" man zshall; }
# transmission-remote
if is-callable 'transmission-remote'; then
alias bt='transmission-remote server'
# pretty print torrent list on remote server
function btl {
results=`transmission-remote server -l | \
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'`
if [ -z "$results" ]; then
echo "No torrents!"
else
echo $results
fi
} }
fi
# Editors
unalias e
v() { [ $# -eq 0 ] && vim . || vim $@ }
e() { # emacs
[ $# -eq 0 ] && input=$@
emacsclient -n ${input:-.}
}
# Compilers 'n interpretors
alias va='vagrant'
alias py='python'
alias pye='pyenv'
alias pip='sudo pip'
alias rb='ruby'
alias rbe='rbenv'
alias b='bundle'
alias be='bundle exec'
alias bi='bundle install -path vendor'
alias c11='clang++ -std=c++11 -stdlib=libc++'
alias eclimd='/Applications/eclipse/eclimd'
# GIT
is-callable 'hub' && alias git='hub'
g() { [ $# -eq 0 ] && git status --short || git $* }
alias gi='git init'
alias gs='git status'
alias gco='git checkout'
alias gc='git commit'
alias gcm='noglob git commit -m'
alias gc='git diff'
alias gp='git push'
alias gl='git pull'
alias ga='git add'
alias gb='git branch'
alias gap='git add --patch'
alias gr='git reset "HEAD^"'
# Tmux
if is-callable 'tmux'; then
alias t='tmux'
alias ts='tmux send-keys'
alias tl='tmux ls'
# Start new session or create a grouped session so I'm not simply watching
# the same session in both windows.
alias ta='tmux new -s $(hostname) || tmux new -t $(hostname) -s $(hostname)-2 || tmux attach -t "io-2"'
# New instance attached to old session
alias tn='tmux new-session -t $(hostname)'
fi

View file

@ -3,8 +3,6 @@ export GIT_MERGE_AUTOEDIT=no
# Disable autocorrect behavior, very annoying! # Disable autocorrect behavior, very annoying!
unsetopt correct_all unsetopt correct_all
autoload -Uz zmv
################# #################
# Keybindings # # Keybindings #

View file

@ -48,7 +48,7 @@ function prompt_v0_setup {
zstyle ':prezto:module:editor:info:completing' format '%B%F{red}...%f%b' zstyle ':prezto:module:editor:info:completing' format '%B%F{red}...%f%b'
zstyle ':prezto:module:editor:info:keymap:primary' format '%B%F{red}$%f%b' zstyle ':prezto:module:editor:info:keymap:primary' format '%B%F{red}$%f%b'
zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format '%F{red}♺%f' zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format '%F{red}♺%f'
zstyle ':prezto:module:editor:info:keymap:alternate' format '%B%F{green}|%f%b' zstyle ':prezto:module:editor:info:keymap:alternate' format '%B%F{green}#%f%b'
# Add newline before prompt # Add newline before prompt
precmd() { print "" } precmd() { print "" }

4
zshenv
View file

@ -3,6 +3,4 @@ if [[ "$SHLVL" -eq 1 && ! -o LOGIN && -s "${ZDOTDIR:-$HOME}/.zprofile" ]]; then
source "${ZDOTDIR:-$HOME}/.zprofile" source "${ZDOTDIR:-$HOME}/.zprofile"
fi fi
if [[ -n "$EMACS" ]]; then [[ -n "$EMACS" ]] && source "${ZDOTDIR:-$HOME}/.zshrc"
source "${ZDOTDIR:-$HOME}/.zshrc"
fi

18
zshrc
View file

@ -4,29 +4,23 @@ if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
else else
echo "Prezto isn't installed! Run ~/.dotfiles/install.sh" echo "Prezto isn't installed! Run ~/.dotfiles/install.sh"
exit 1
fi fi
source ~/.zsh/aliases
# Source component rcfiles # Source component rcfiles
if [[ -z "$EMACS" ]]; then if [[ -z "$EMACS" ]]; then
source ~/.zsh/config source ~/.zsh/config
is-callable 'fasd' && eval "$(fasd --init auto)" is-callable 'fasd' && eval "$(fasd --init auto)"
fi fi
source ~/.zsh/aliases
# Initialize rbenv and pyenv; rehashing slows down zsh startup, so we
# disable it.
if is-callable 'rbenv'; then if is-callable 'rbenv'; then
export PATH=~/.rbenv/bin:$PATH
eval "$(rbenv init - --no-rehash)" eval "$(rbenv init - --no-rehash)"
fi fi
if is-callable 'pyenv'; then if is-callable 'pyenv'; then
export PATH=~/.pyenv/bin:~/.pyenv/shims:$PATH
eval "$(pyenv init - --no-rehash)" eval "$(pyenv init - --no-rehash)"
eval "$(pyenv virtualenv-init -)"
fi fi
# if is-callable 'go'; then
# export GOPATH="$HOME/Dropbox/Projects/dev/go"
# export PATH="$GOPATH/bin:$PATH"
# fi
# if is-callable 'haxe'; then
# export HAXE_STD_PATH="/usr/local/lib/haxe/std"
# fi