# Path stuff. This accounts for, at least:
|
|
#
|
|
# - a custom Firefox install
|
|
# - some bin dirs in my homedir
|
|
# - golang
|
|
# - some Chef bullshit
|
|
# - ansible
|
|
#
|
|
# Beware that other modifications to path might be made in .zshrc or .bashrc
|
|
export GOPATH=~/gocode
|
|
export PATH=~/code/ansible/bin:~/firefox:~/bin:~/.xmonad:/usr/local/bin:~/.local/bin/:$PATH:$GOPATH/bin:~/.chefdk/gem/ruby/2.3.0/bin
|
|
|
|
# Needed for ansible - wouldn't surprise me if this interfered with other
|
|
# things:
|
|
export PYTHONPATH=~/code/ansible/lib
|
|
|
|
# Debian stuff:
|
|
export DEBEMAIL="bbearnes@gmail.com"
|
|
export DEBFULLNAME="Brennen Bearnes"
|
|
|
|
# Explicitly set default editor:
|
|
export EDITOR=`which vim`
|
|
|
|
# Configure less(1):
|
|
export LESS='-FiRSX'
|
|
|
|
# Configure fzf fuzzyfinder:
|
|
export FZF_CTRL_R_OPTS='-e' # exact match by default - see fzf(1)
|
|
|
|
# Aliases, various and sundry: {{{
|
|
alias ac='apt-cache'
|
|
alias agu='sudo apt-get update && sudo apt-get upgrade'
|
|
alias c="commandlog"
|
|
alias g='git'
|
|
alias gitsu='git submodule sync && git submodule update'
|
|
alias l='ls -CF'
|
|
alias la='ls -A'
|
|
alias lal='ls -Al'
|
|
alias lah='ls -Alh'
|
|
alias ll='ls -l'
|
|
alias ls='ls --color'
|
|
alias m='make'
|
|
alias s='sudo'
|
|
alias st='mr -m stat' # myrepo status, minimal output
|
|
alias v='vim'
|
|
alias vt='vim `todaydir`'
|
|
|
|
# How big is the terminal?
|
|
alias dim='echo $(tput cols)x$(tput lines)'
|
|
|
|
# vi life:
|
|
alias :e='vim'
|
|
alias :q='exit'
|
|
alias :wq='exit'
|
|
alias :r='cat'
|
|
|
|
# Navigation:
|
|
alias p='cd ~/p1k3'
|
|
alias ct='cd `todaydir`'
|
|
|
|
# Get a persistent directory history menu in fzf - originally written for dmenu
|
|
# and inspired by jholland at:
|
|
# http://hints.macworld.com/article.php?story=20050806202859392
|
|
# I get the feeling that there's probably a more idiomatic way to do what
|
|
# I want here, but for the moment it's nice. See: https://p1k3.com/2016/5/17/
|
|
alias h='cd $(tail -500 ~/.directory_history | sed "s/^:[^;]*;//" | tac | unsorted-unique | fzf --height=50%); rash search --cwd .'
|
|
|
|
alias ack='ack-grep'
|
|
|
|
# }}}
|
|
|
|
# Functions: {{{
|
|
|
|
function parse_git_branch {
|
|
# Formerly:
|
|
# ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
|
# echo "("${ref#refs/heads/}") "
|
|
|
|
# Largely borrowed from:
|
|
# https://github.com/robacarp/config_files/commit/5d983240d509bf4f7815ed822c0e868ccce08a79
|
|
git_status=$(git status --porcelain -b 2> /dev/null) || return
|
|
|
|
echo $git_status | awk '
|
|
BEGIN {
|
|
status["untracked"] = 0
|
|
status["modifications"] = 0
|
|
status["unmerged"] = 0
|
|
}
|
|
$1 ~ /##/ {
|
|
split($2, branch_names, ".")
|
|
}
|
|
$1 ~ /\?\?/ { status["untracked"] ++ }
|
|
$1 ~ /M/ { status["modifications"] ++ }
|
|
$1 ~ /[DAU][DAU]/ { status["unmerged"] ++ }
|
|
END {
|
|
printf "(%s %i/%i) ", branch_names[1], status["modifications"], status["untracked"]
|
|
}
|
|
'
|
|
}
|
|
|
|
# }}}
|