My dotfiles. Period.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #!/bin/bash
  2. ## hack to workaround Fedora/Red Hat bug 878428
  3. test -f /usr/share/git-core/contrib/completion/git-prompt.sh \
  4. && . /usr/share/git-core/contrib/completion/git-prompt.sh
  5. #######################################################
  6. ### things to do BEFORE host/user-specific settings ###
  7. #######################################################
  8. ### .... ###
  9. ### SUBZ ###
  10. ### '''' ###
  11. git() {
  12. if grep -Fwqse "$1" "$GIT_DISABLED_COMMANDS"; then
  13. echo "You don't want this." >&2
  14. return 1
  15. else
  16. command git "$@"
  17. fi
  18. }
  19. grepr() {
  20. local p=$1; shift
  21. grep --color -n --exclude-dir=".git" -e "$p" -r "$@"
  22. }
  23. greph() {
  24. history | sed 's/^ *//; s/ / /' | cut -d' ' -f2- | grep "$@"
  25. }
  26. gitcd() {
  27. cd "$(git rev-parse --show-toplevel)"
  28. }
  29. clsz() {
  30. tput clear; tput cup "$(tput lines)" 0
  31. }
  32. bcdiff() {
  33. test $# -eq 2 && diff "$@" >/dev/null && return
  34. bcompare "$@" &
  35. }
  36. vims() {
  37. # 2015-07-10 06:10:48.603953758 +0200 ~/TODO.todo
  38. local swap="$HOME/.local/share/vim/swap"
  39. find "$swap" -type f -print0 \
  40. | xargs -0 -r stat -c "%y %n" \
  41. | sed "
  42. s| $swap/| |
  43. s|%|/|g
  44. s|.swp$||
  45. s| $HOME| ~|
  46. s| \(..:..\):[^ ]* +.... | \\1 |
  47. " \
  48. | sort \
  49. | tac
  50. }
  51. xod() {
  52. # dump xo in a file named $1 somewhere in /tmp; echo the path
  53. # usage: scp $(xod useful_name.txt) eg:some/shared/place
  54. # instead of xo>useful_name.txt; scp useful_name.txt eg:some/shared/place; rm useful_name.txt
  55. local name="${1:-clipboard_dump.txt}"
  56. local tmp=$(mktemp -d -t "xod.XXXXXXXX")
  57. xclip -o > "$tmp/$name"
  58. echo "$tmp/$name"
  59. }
  60. xood() {
  61. # just like xod() but using xoo
  62. local name="${1:-clipboard_dump.txt}"
  63. local tmp=$(mktemp -d -t "xood.XXXXXXXX")
  64. xclip -selection clipboard -o > "$tmp/$name"
  65. echo "$tmp/$name"
  66. }
  67. yum_hasbin() {
  68. local bname
  69. for bname in "$@";
  70. do
  71. yum provides "*bin/$bname" \
  72. | grep '^.' \
  73. | grep -E '^[0-9a-zA-Z_:.-]+ :'
  74. done
  75. }
  76. ### .... ###
  77. ### BASH ###
  78. ### '''' ###
  79. HISTCONTROL=erasedups
  80. HISTIGNORE="$HISTIGNORE:ls:ll:la:cd"
  81. HISTIGNORE="$HISTIGNORE:git dc:git st"
  82. #export HISTIGNORE="$HISTIGNORE:se *:sc *"
  83. HISTSIZE=-1
  84. HISTFILESIZE=100000
  85. GLOBIGNORE=.:..
  86. shopt -s histverify
  87. # some more aliases
  88. alias cal='cal -m'
  89. alias cls='clear'
  90. alias ll='ls -lh'
  91. alias lla='ls -lha'
  92. alias open='gnome-open'
  93. alias diff='diff -u'
  94. alias dmesg='dmesg --time-format iso'
  95. alias pad4='sed -e "/./s/^/ /"'
  96. alias grep='grep --color --binary-files=without-match'
  97. alias sc='se --direction=encz.cz'
  98. alias ts='ts "%F %T"'
  99. alias lsblk='lsblk -o +UUID,LABEL'
  100. alias virsh='virsh --connect qemu:///system'
  101. alias xaa='xclip -o | audit2allow'
  102. alias xi='xclip -i'
  103. alias xii='xclip -selection clipboard -i'
  104. alias xo='xclip -o'
  105. alias xoo='xclip -selection clipboard -o'
  106. RV_TMP="/tmp/bash-rv"
  107. mkdir -p "$RV_TMP"
  108. ### ...... ###
  109. ### OTHERS ###
  110. ### '''''' ###
  111. export LC_COLLATE=C # make sort upper first
  112. export SHELLFU_PRETTY=color
  113. export SHELLFU_DEBUG_EXCLUDE=inigrep
  114. # make green git bash trinket even cooler
  115. GIT_PS1_SHOWDIRTYSTATE=true
  116. GIT_PS1_SHOWUNTRACKEDFILES=true
  117. GIT_DISABLED_COMMANDS="$HOME/.gittum/disabled-commands"
  118. export GIT_PAGER='less -S'
  119. # disable mounting things like SFTP to ~/.gvfs when accessed
  120. # via GIO (used by nautilus etc.)
  121. export GVFS_DISABLE_FUSE=1
  122. # disable the terrible beep sound (only for X; for tty?, blacklist pcspkr)
  123. [[ ${!DISPLAY[@]} ]] && xset b off
  124. # get rid of those .pyc files once and for all
  125. export PYTHONDONTWRITEBYTECODE=1
  126. ssh-add -l >& /dev/null || ssh-add