My dotfiles. Period.

main.bashrc 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. <"$HOME/.bash_history" 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. yum_hasbin() {
  52. local bname
  53. for bname in "$@";
  54. do
  55. yum provides "*bin/$bname" \
  56. | grep '^.' \
  57. | grep -E '^[0-9a-zA-Z_:.-]+ :'
  58. done
  59. }
  60. ### .... ###
  61. ### BASH ###
  62. ### '''' ###
  63. HISTCONTROL=erasedups
  64. HISTIGNORE="$HISTIGNORE:ls:ll:la:cd"
  65. HISTIGNORE="$HISTIGNORE:git dc:git st"
  66. #export HISTIGNORE="$HISTIGNORE:se *:sc *"
  67. HISTSIZE=-1
  68. HISTFILESIZE=100000
  69. GLOBIGNORE=.:..
  70. # some more aliases
  71. alias cal='cal -m'
  72. alias cls='clear'
  73. alias ll='ls -lh'
  74. alias lla='ls -lha'
  75. alias open='gnome-open'
  76. alias diff='diff -u'
  77. alias dmesg='dmesg --time-format iso'
  78. alias pad4='sed -e "/./s/^/ /"'
  79. alias grep='grep --color --binary-files=without-match'
  80. alias sc='se --direction=encz.cz'
  81. alias ts='ts "%F %T"'
  82. alias lsblk='lsblk -o +UUID,LABEL'
  83. alias virsh='virsh --connect qemu:///system'
  84. alias xaa='xclip -o | audit2allow'
  85. alias xi='xclip -i'
  86. alias xii='xclip -selection clipboard -i'
  87. alias xo='xclip -o'
  88. alias xoo='xclip -selection clipboard -o'
  89. RV_TMP="/tmp/bash-rv"
  90. mkdir -p "$RV_TMP"
  91. ### ...... ###
  92. ### OTHERS ###
  93. ### '''''' ###
  94. export LC_COLLATE=C # make sort upper first
  95. export FFOO_PRETTY=color
  96. # make green git bash trinket even cooler
  97. GIT_PS1_SHOWDIRTYSTATE=true
  98. GIT_PS1_SHOWUNTRACKEDFILES=true
  99. GIT_DISABLED_COMMANDS="$HOME/.gittum/disabled-commands"
  100. export GIT_PAGER='less -S'
  101. # disable mounting things like SFTP to ~/.gvfs when accessed
  102. # via GIO (used by nautilus etc.)
  103. export GVFS_DISABLE_FUSE=1
  104. # disable the terrible beep sound (only for X; for tty?, blacklist pcspkr)
  105. [[ ${!DISPLAY[@]} ]] && xset b off
  106. # get rid of those .pyc files once and for all
  107. export PYTHONDONTWRITEBYTECODE=1
  108. ssh-add -l >& /dev/null || ssh-add