.bashrc 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #for script in "$SH_DIR"/*.sh ; do # Does not work. Don't know why.
  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 newMusic='ecex sudo chown media /tmp/*.mp3 && ecex sudo -u media mv -v /tmp/*.mp3 /media/music && ecex mpc update'
  54. alias playMusic='ecex mpc clear && ecex getLyricalSongs | ecex mpc add && ecex mpc shuffle && ecex mpc play'
  55. alias conServer='ecex ssh tflucke@63.246.2.164'
  56. alias packageSize="pacman -Qi | gawk '/^Name/ { x = $3 }; /^Installed Size/ { sub(/Installed Size *:/, ""); print x":" $0 }' | sort -k2,3nr"
  57. #[ $exitCode -eq 0 ] && color=$FGRN || color=$FRED
  58. PS1="[\u@\h->$BLD\w$RS]
  59. $BLD$([ $? -ne 0 ] && echo '\[$FRED')(\$?)$RS \$ "
  60. # Auto mount
  61. # Mounts or unmounts intelligently. Useful for keyboard bindings
  62. amount () {
  63. if mount | grep -q "/dev/$1"; then
  64. udevil umount -l "/dev/$1"
  65. else
  66. udevil mount "/dev/$1"
  67. fi
  68. }
  69. mysqlpermissions()
  70. {
  71. mysql -B -N $@ -e "SELECT DISTINCT CONCAT(
  72. 'SHOW GRANTS FOR \'', user, '\'@\'', host, '\';'
  73. ) AS query FROM mysql.user" | \
  74. mysql $@ | \
  75. sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'
  76. }
  77. # Syncs music dir to dir. Useful for syncing phone music.
  78. syncMusic()
  79. {
  80. ecex rsync -ruh --progress "$MUSIC_DIR" "$1"
  81. }