Dotfiles, utilities, and other apparatus.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
3.1 KiB

13 years ago
8 years ago
12 years ago
  1. # Path stuff. This accounts for, at least:
  2. #
  3. # - a custom Firefox install
  4. # - some bin dirs in my homedir
  5. # - golang
  6. #
  7. # Beware that other modifications to path might be made in .zshrc or .bashrc
  8. # - and that _probably_ this should live somewhere that sets the environment for
  9. # the entire X session. It's a tangled mess which certainly warrants a TODO.
  10. export GOPATH=~/code/go
  11. export PATH=~/firefox:~/bin:~/notes/bin:~/.xmonad:/usr/local/bin:~/.local/bin/:$PATH:/usr/local/go/bin:$GOPATH/bin
  12. # Needed for ansible - wouldn't surprise me if this interfered with other
  13. # things:
  14. export PYTHONPATH=~/code/ansible/lib
  15. # Debian stuff:
  16. export DEBEMAIL="bbearnes@gmail.com"
  17. export DEBFULLNAME="Brennen Bearnes"
  18. # Explicitly set default editor:
  19. export EDITOR=`which vim`
  20. # Configure less(1):
  21. export LESS='-FiRSX'
  22. # Configure fzf fuzzyfinder:
  23. export FZF_CTRL_R_OPTS='-e' # exact match by default - see fzf(1)
  24. # Aliases, various and sundry: {{{
  25. alias ac='apt-cache'
  26. alias agu='sudo apt-get update && sudo apt-get upgrade'
  27. alias c="commandlog"
  28. alias g='git'
  29. alias gitsu='git submodule sync && git submodule update'
  30. alias l='ls -CF'
  31. alias la='ls -A'
  32. alias lal='ls -Al'
  33. alias lah='ls -Alh'
  34. alias ll='ls -l'
  35. alias ls='ls --color'
  36. alias m='make'
  37. alias mk='mark'
  38. alias mka='mark add'
  39. alias s='sudo'
  40. alias v='vim'
  41. alias vt='vim `todaydir`'
  42. # How big is the terminal?
  43. alias dim='echo $(tput cols)x$(tput lines)'
  44. # vi life:
  45. alias :e='vim'
  46. alias :q='exit'
  47. alias :wq='exit'
  48. alias :r='cat'
  49. # Navigation:
  50. alias p='cd ~/p1k3'
  51. alias ct='cd `todaydir`'
  52. # Get a persistent directory history menu in fzf - originally written for dmenu
  53. # and inspired by jholland at:
  54. # http://hints.macworld.com/article.php?story=20050806202859392
  55. # I get the feeling that there's probably a more idiomatic way to do what
  56. # I want here, but for the moment it's nice. See: https://p1k3.com/2016/5/17/
  57. alias h='cd $(tail -3000 ~/.directory_history | sed "s/^:[^;]*;//" | tac | unsorted-unique | fzf --height=50%); rash search --cwd .'
  58. # Get a menu of command history for the current directory; execute the selected one.
  59. alias hm='eval $(rash search --cwd . --sort-by time --limit 0 | grep -vE "^(ls|ll|l|cd|p|fg|hm|st)$" | fzf --height=50%)'
  60. # }}}
  61. # Functions: {{{
  62. # Create a directory (if it doesn't exist) and cd to it:
  63. function mcd {
  64. mkdir -p $1 && cd $1
  65. }
  66. function parse_git_branch {
  67. # Formerly:
  68. # ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  69. # echo "("${ref#refs/heads/}") "
  70. # Largely borrowed from:
  71. # https://github.com/robacarp/config_files/commit/5d983240d509bf4f7815ed822c0e868ccce08a79
  72. git_status=$(git status --porcelain -b 2> /dev/null) || return
  73. echo $git_status | awk '
  74. BEGIN {
  75. status["untracked"] = 0
  76. status["modifications"] = 0
  77. status["unmerged"] = 0
  78. }
  79. $1 ~ /##/ {
  80. gsub(/\.\.\..*/, "")
  81. branch_name=$2
  82. }
  83. $1 ~ /\?\?/ { status["untracked"] ++ }
  84. $1 ~ /M/ { status["modifications"] ++ }
  85. $1 ~ /[DAU][DAU]/ { status["unmerged"] ++ }
  86. END {
  87. printf "(%s %i/%i) ", branch_name, status["modifications"], status["untracked"]
  88. }
  89. '
  90. }
  91. # }}}