2011-09-13 11:25:45 -07:00
|
|
|
# .rc
|
2011-05-03 21:53:50 -07:00
|
|
|
# vim: ft=zsh
|
|
|
|
# Generic interactive shell setup
|
2011-11-30 13:12:07 -08:00
|
|
|
# Eryn Wells <eryn@erynwells.me>
|
2011-05-03 21:53:50 -07:00
|
|
|
|
2012-11-29 15:18:57 -08:00
|
|
|
print_heading -l 1 'Initializing interactive shell'
|
2012-07-20 09:36:00 -07:00
|
|
|
|
2012-11-29 15:18:57 -08:00
|
|
|
print_info -l 2 'Creating aliases'
|
2013-09-05 07:48:17 -07:00
|
|
|
alias j='jobs'
|
2011-05-03 21:53:50 -07:00
|
|
|
alias h='history'
|
|
|
|
alias df='df -h'
|
|
|
|
alias du='du -h'
|
2014-08-22 08:05:15 -07:00
|
|
|
alias e='emacs'
|
2012-07-20 09:19:54 -07:00
|
|
|
|
2012-07-20 09:36:00 -07:00
|
|
|
binary_exists ledger && alias l='ledger'
|
2012-07-20 09:19:54 -07:00
|
|
|
|
2014-04-17 22:33:57 -07:00
|
|
|
binary_exists gpg2 && alias gpg='gpg2'
|
2017-01-26 19:32:42 -08:00
|
|
|
binary_exists keybase && alias keybase="keybase --gpg \"`which gpg2`\""
|
2014-04-17 22:33:57 -07:00
|
|
|
|
2012-09-28 19:47:32 -07:00
|
|
|
alias chux='chmod u+x'
|
|
|
|
alias chuw='chmod u+w'
|
|
|
|
alias chur='chmod u+r'
|
|
|
|
alias cho="chown $USER"
|
2011-05-03 21:53:50 -07:00
|
|
|
|
|
|
|
alias today='date +%Y-%m-%d'
|
|
|
|
|
|
|
|
alias addkey="ssh-agent ~/.ssh/id_rsa"
|
2011-11-30 13:06:52 -08:00
|
|
|
|
2012-09-28 12:25:22 -07:00
|
|
|
alias pprint="python -c 'import sys,pprint; pprint.pprint(eval(sys.stdin.read()))'"
|
2012-04-11 09:56:27 -07:00
|
|
|
alias pprint-json="python -c 'import sys,json;print json.dumps(json.load(sys.stdin), indent=2)'"
|
2012-04-17 23:35:12 -07:00
|
|
|
|
2016-09-16 14:08:07 -07:00
|
|
|
#
|
|
|
|
# Git
|
|
|
|
#
|
|
|
|
|
2013-03-12 15:39:46 -07:00
|
|
|
function g
|
|
|
|
{
|
|
|
|
if [[ $# -gt 0 ]]; then
|
|
|
|
git $@
|
|
|
|
else
|
|
|
|
git status --short --branch
|
|
|
|
fi
|
2013-03-12 15:48:56 -07:00
|
|
|
return $?
|
2013-03-12 15:39:46 -07:00
|
|
|
}
|
|
|
|
|
2017-10-26 15:06:09 -07:00
|
|
|
function vi
|
|
|
|
{
|
2018-09-16 14:19:29 -07:00
|
|
|
if whence -cp nvim 1>/dev/null 2>&1; then
|
2017-10-26 15:06:09 -07:00
|
|
|
command nvim $@
|
2018-09-16 14:19:29 -07:00
|
|
|
elif whence -cp vim 1>/dev/null 2>&1; then
|
2017-10-26 15:06:09 -07:00
|
|
|
command vim $@
|
2018-09-16 14:19:29 -07:00
|
|
|
elif whence -cp vi 1>/dev/null 2>&1; then
|
2017-10-26 15:06:09 -07:00
|
|
|
command vi $@
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-09-16 14:08:07 -07:00
|
|
|
alias gp='g p origin $gitbranch'
|
|
|
|
alias gpf='g p -f origin $gitbranch'
|
|
|
|
|
|
|
|
#
|
|
|
|
# Setup
|
|
|
|
#
|
2012-09-28 12:25:22 -07:00
|
|
|
|
2013-09-04 20:26:10 -07:00
|
|
|
function configure_ls
|
|
|
|
{
|
|
|
|
local has_gnu_ls
|
|
|
|
local ls_options
|
|
|
|
|
|
|
|
if [[ ! -e "$1" ]]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
if $1 --version 2>&1 | grep GNU 1>/dev/null; then
|
|
|
|
has_gnu_ls=1
|
|
|
|
ls_options='--color=auto'
|
2013-08-07 22:43:53 -07:00
|
|
|
else
|
|
|
|
has_gnu_ls=0
|
|
|
|
ls_options='-G'
|
|
|
|
fi
|
2012-09-28 12:25:22 -07:00
|
|
|
|
2013-09-04 20:26:10 -07:00
|
|
|
print_info_sub -l 3 "Setting up ls: $1"
|
|
|
|
alias ls="$1 $ls_options"
|
|
|
|
alias la="$1 -A $ls_options"
|
|
|
|
alias ll="$1 -l $ls_options"
|
|
|
|
alias l.="$1 -d $ls_options .*"
|
2012-09-28 12:25:22 -07:00
|
|
|
|
2013-09-09 11:12:49 -07:00
|
|
|
local dircolors_bin=`whence -p dircolors || whence -p gdircolors`
|
|
|
|
if [[ $has_gnu_ls -eq 1 && -n "$dircolors_bin" ]]; then
|
2013-08-07 22:43:53 -07:00
|
|
|
if [[ -e "$HOME/.dircolors/$SYS.cfg" ]]; then
|
|
|
|
dircolors="$HOME/.dircolors/$SYS.cfg"
|
2012-09-28 12:25:22 -07:00
|
|
|
else
|
2013-08-07 22:43:53 -07:00
|
|
|
dircolors="$HOME/.dircolors/default.cfg"
|
2012-09-28 12:25:22 -07:00
|
|
|
fi
|
2012-11-29 15:18:57 -08:00
|
|
|
print_info_sub -l 3 "Setting up dircolors: `basename $dircolors`"
|
2013-09-09 11:12:49 -07:00
|
|
|
eval `$dircolors_bin $dircolors`
|
2012-09-28 12:25:22 -07:00
|
|
|
fi
|
|
|
|
}
|
2012-08-07 11:19:43 -07:00
|
|
|
|
2013-09-04 20:26:10 -07:00
|
|
|
|
2012-08-07 11:19:43 -07:00
|
|
|
# NetHack options
|
|
|
|
# use color in the terminal
|
2012-09-28 12:25:22 -07:00
|
|
|
binary_exists nethack && export NETHACKOPTIONS="color"
|
2012-08-07 11:19:43 -07:00
|
|
|
|
|
|
|
# Default ledger file
|
2018-09-16 14:19:29 -07:00
|
|
|
[[ -e "$HOME/Documents/Ledger/personal.ledger" ]] && \
|
|
|
|
LEDGER_FILE=$HOME/Documents/Ledger/personal.ledger
|
2012-08-07 11:19:43 -07:00
|
|
|
|
2013-09-04 20:26:10 -07:00
|
|
|
if [[ -e "$HOME/.rc.$SYS" ]]; then
|
2014-05-22 19:18:14 -07:00
|
|
|
print_info -l 2 "Sourcing $SYS interactive shell setup"
|
2013-09-04 20:26:10 -07:00
|
|
|
source "$HOME/.rc.$SYS"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Set up ls if it wasn't already done.
|
|
|
|
if ! alias ls 2>&1 1>/dev/null; then
|
|
|
|
configure_ls `which ls`
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -e "$HOME/.rc.local" ]]; then
|
2012-11-29 15:18:57 -08:00
|
|
|
print_info -l 2 'Sourcing local interactive shell setup'
|
2013-09-04 20:26:10 -07:00
|
|
|
source "$HOME/.rc.local"
|
2012-08-17 12:48:04 -07:00
|
|
|
fi
|