My dotfiles. Period.

main.bashrc 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. # some more aliases
  87. alias cal='cal -m'
  88. alias cls='clear'
  89. alias ll='ls -lh'
  90. alias lla='ls -lha'
  91. alias open='gnome-open'
  92. alias diff='diff -u'
  93. alias dmesg='dmesg --time-format iso'
  94. alias pad4='sed -e "/./s/^/ /"'
  95. alias grep='grep --color --binary-files=without-match'
  96. alias sc='se --direction=encz.cz'
  97. alias ts='ts "%F %T"'
  98. alias lsblk='lsblk -o +UUID,LABEL'
  99. alias virsh='virsh --connect qemu:///system'
  100. alias xaa='xclip -o | audit2allow'
  101. alias xi='xclip -i'
  102. alias xii='xclip -selection clipboard -i'
  103. alias xo='xclip -o'
  104. alias xoo='xclip -selection clipboard -o'
  105. RV_TMP="/tmp/bash-rv"
  106. mkdir -p "$RV_TMP"
  107. ### ...... ###
  108. ### OTHERS ###
  109. ### '''''' ###
  110. export LC_COLLATE=C # make sort upper first
  111. export SHELLFU_PRETTY=color
  112. export SHELLFU_DEBUG_EXCLUDE=inigrep
  113. # make green git bash trinket even cooler
  114. GIT_PS1_SHOWDIRTYSTATE=true
  115. GIT_PS1_SHOWUNTRACKEDFILES=true
  116. GIT_DISABLED_COMMANDS="$HOME/.gittum/disabled-commands"
  117. export GIT_PAGER='less -S'
  118. # disable mounting things like SFTP to ~/.gvfs when accessed
  119. # via GIO (used by nautilus etc.)
  120. export GVFS_DISABLE_FUSE=1
  121. # disable the terrible beep sound (only for X; for tty?, blacklist pcspkr)
  122. [[ ${!DISPLAY[@]} ]] && xset b off
  123. # get rid of those .pyc files once and for all
  124. export PYTHONDONTWRITEBYTECODE=1
  125. ssh-add -l >& /dev/null || ssh-add