|
|
- # Path stuff. This accounts for, at least:
- #
- # - a custom Firefox install
- # - some bin dirs in my homedir
- # - golang
- #
- # Beware that other modifications to path might be made in .zshrc or .bashrc
- # - and that _probably_ this should live somewhere that sets the environment for
- # the entire X session. It's a tangled mess which certainly warrants a TODO.
-
- export GOPATH=~/code/go
- export PATH=~/firefox:~/bin:~/notes/bin:~/.xmonad:/usr/local/bin:~/.local/bin/:$PATH:/usr/local/go/bin:$GOPATH/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 mk='mark'
- alias mka='mark add'
- alias s='sudo'
- 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 -3000 ~/.directory_history | sed "s/^:[^;]*;//" | tac | unsorted-unique | fzf --height=50%); rash search --cwd .'
-
- # Get a menu of command history for the current directory; execute the selected one.
- alias hm='eval $(rash search --cwd . --sort-by time --limit 0 | grep -vE "^(ls|ll|l|cd|p|fg|hm|st)$" | fzf --height=50%)'
-
- # }}}
-
- # Functions: {{{
-
- # Create a directory (if it doesn't exist) and cd to it:
- function mcd {
- mkdir -p $1 && cd $1
- }
-
- 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 ~ /##/ {
- gsub(/\.\.\..*/, "")
- branch_name=$2
- }
- $1 ~ /\?\?/ { status["untracked"] ++ }
- $1 ~ /M/ { status["modifications"] ++ }
- $1 ~ /[DAU][DAU]/ { status["unmerged"] ++ }
- END {
- printf "(%s %i/%i) ", branch_name, status["modifications"], status["untracked"]
- }
- '
- }
-
- # }}}
|