.bashrc 2.5 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. 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 emacs='emacs -nw'
  50. alias xterm='ecex xterm -rv'
  51. alias decks='ecex "$MTG_DIR" && ecex mv /tmp/*.dec "$MTG_DIR"'
  52. alias newMusic='ecex sudo chown media /tmp/*.mp3 && ecex sudo -u media mv -v /tmp/*.mp3 /media/music && ecex mpc update'
  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. }