.bashrc 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #
  2. # ~/.bashrc
  3. #
  4. # If not running interactively, don't do anything
  5. [[ $- != *i* ]] && return
  6. MUSIC_DIR="/media/music"
  7. MTG_DIR="~/.local/share/data/Cockatrice/Cockatrice/decks"
  8. SH_DIR="~/.config/env"
  9. SERVER_IP="63.246.2.164"
  10. export EDITOR="/usr/bin/emacs -nw"
  11. export BROWSER=/usr/bin/firefox
  12. export TERM=xterm-256color
  13. shopt -s checkwinsize
  14. shopt -s autocd
  15. shopt -s dirspell
  16. shopt -s xpg_echo
  17. # Set up history search
  18. bind '"\e[A": history-search-backward'
  19. bind '"\e[B": history-search-forward'
  20. export HISTCONTROL=ignoredups
  21. # Set up left/right word skipping
  22. bind '"\e[1;5D": backward-word'
  23. bind '"\e[1;5C": forward-word'
  24. # List of directories to look for git completion
  25. gitCompletion="/usr/share/git/completion/git-completion.bash /usr/share/bash-completion/completions/git"
  26. for f in $gitCompletion; do
  27. if [ -f "$f" ]; then
  28. source "$f"
  29. fi
  30. done
  31. # TODO: Can't use SH_DIR, doesn't expand with *.
  32. for script in ~/.config/env/*.sh; do
  33. source "$script"
  34. done
  35. getLyricalSongs()
  36. {
  37. mpc list album | grep -v '\(Portal 2.*\)\|\(Avatar.*\)\|\(Frozen.*\)' | while read -r line; do
  38. printf "$(mpc find album "$line" | grep -v 'Instrumental')\n"
  39. done
  40. }
  41. # echo exec
  42. # Print command and execute ala make
  43. #if type -t ecex; then
  44. ecex()
  45. {
  46. echo "$@"
  47. $@
  48. }
  49. #alias xterm='echo "xterm -rv" && xterm -rv'
  50. alias emacs='emacs -nw'
  51. alias xterm='ecex xterm -rv'
  52. alias decks='ecex "$MTG_DIR" && ecex mv /tmp/*.dec "$MTG_DIR"'
  53. alias playMusic='ecex mpc clear && ecex getLyricalSongs | ecex mpc add && ecex mpc shuffle && ecex mpc play'
  54. alias conServer='ecex ssh tflucke@63.246.2.164'
  55. alias packageSize="pacman -Qi | gawk '/^Name/ { x = $3 }; /^Installed Size/ { sub(/Installed Size *:/, ""); print x":" $0 }' | sort -k2,3nr"
  56. #[ $exitCode -eq 0 ] && color=$FGRN || color=$FRED
  57. PS1="[\u@\h->$BLD\w$RS]
  58. $BLD$([ $? -ne 0 ] && echo '\[$FRED')(\$?)$RS \$ "
  59. # Auto mount
  60. # Mounts or unmounts intelligently. Useful for keyboard bindings
  61. amount () {
  62. if mount | grep -q "/dev/$1"; then
  63. udevil umount -l "/dev/$1"
  64. else
  65. udevil mount "/dev/$1"
  66. fi
  67. }
  68. mysqlpermissions()
  69. {
  70. mysql -B -N $@ -e "SELECT DISTINCT CONCAT(
  71. 'SHOW GRANTS FOR \'', user, '\'@\'', host, '\';'
  72. ) AS query FROM mysql.user" | \
  73. mysql $@ | \
  74. sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'
  75. }
  76. # Syncs music dir to dir. Useful for syncing phone music.
  77. syncMusic()
  78. {
  79. ecex rsync -ruh --progress "$MUSIC_DIR" "$1"
  80. }