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.

112 lines
3.1 KiB

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