.bashrc 2.5 KB

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