export 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. ##### My (demuredemeanor) bashrc sub source export script
  2. # Uses tabstop=4; shiftwidth=4 tabs; foldmarker={{{,}}};
  3. # https://notabug.org/demure/dotfiles/
  4. # legacy repo http://github.com/demure/dotfiles
  5. # vim:set syntax=sh:
  6. ### Bash Exports ### {{{
  7. export CLICOLOR="YES" ## Color 'ls', etc.
  8. export EDITOR=vim ## Set default editor
  9. export BROWSER=chromium
  10. export BROWSERCLI=w3m
  11. ## Adding PATH junk
  12. if [ ! -e "${HOME}/.no_path" ]; then
  13. export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/pkg/bin:/usr/local/bin:/usr/local/sbin:${HOME}/projects/personal/scripts:${HOME}/bin:${HOME}/.local/bin:${HOME}/go/bin:/usr/local/games:/usr/games
  14. fi
  15. ### History Settings ### {{{
  16. export HISTSIZE=100000 ## Size of shells hist
  17. export HISTFILESIZE=100000 ## Size of Hist file
  18. export HISTCONTROL=ignoreboth:erasedups
  19. export HISTTIMEFORMAT="%F %T " ## Adds time to history
  20. export HISTIGNORE='ls:bg:fg:history' ## Hist ignores exact match
  21. ### End History Settings ### }}}
  22. ### End Bash Exports ### }}}
  23. ### SSH Agents ### {{{
  24. if [ ! -e "${HOME}/.no_agent" ]; then
  25. if [ -s "${HOME}/.ssh/id_ed25519" ] || [ -s "${HOME}/.ssh/id_rsa" ]; then
  26. ## If there is a ssh key, load key for ssh
  27. __ssh_agent
  28. else
  29. if [ "$(gpg -K 2>/dev/null | awk 'BEGIN {AK=0} /^ssb>?\s/ {if($4=="[A]"){AK=1}} END {print AK}')" -eq 1 ]; then
  30. ## If no ssh key, and if there is a gpg auth key, load gpg key for ssh
  31. __ssh_gpg_agent
  32. fi
  33. fi
  34. fi
  35. ### End SSH Agents ### }}}
  36. ### Grep Options ### {{{
  37. ## So, this code is because even though GREP_OPTIONS are 'dead',
  38. ## some servers still have older than grep 2.20...
  39. ## I'm using awk, as bash doesn't really do decimal
  40. grep_test="$(grep --version 2>/dev/null | awk 'BEGIN {VER=0; CUT=2.20} /^grep/ NR>1{if($NF!~/[a-z]/){VER=$NF}} END {if(VER<CUT){print "lt"} else {print "ge"}}')"
  41. if [ ${grep_test} == "ge" ]; then
  42. ## If new, do it the way grep says to
  43. alias grep='grep --color=auto --exclude-dir=.cvs --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn'
  44. else
  45. ## If old, use GREP_OPTIONS, as --exclude may not exist, and annoying errors!
  46. if echo hello | grep --color=auto l >/dev/null 2>&1; then
  47. GREP_OPTIONS+="--color=auto " GREP_COLOR='1;31'
  48. fi
  49. if echo hello | grep --exclude-dir=a l >/dev/null 2>&1; then
  50. for PATTERN in .cvs .git .hg .svn; do
  51. GREP_OPTIONS+="--exclude-dir=$PATTERN "
  52. done
  53. fi
  54. export GREP_OPTIONS
  55. fi
  56. ### End Grep Options ### }}}
  57. ### z Jump Around ### {{{
  58. if [ ${UID} != '0' ] && [[ $- == *i* ]] && [ ${TERM} != 'dumb' ]; then
  59. if [ $(command -v z.sh) ]; then
  60. ## debian
  61. source $(command -v z.sh)
  62. elif [ -r "/usr/share/z/z.sh" ]; then
  63. ## arch
  64. source /usr/share/z/z.sh
  65. else
  66. MISSING_ITEMS+="z_jump, "
  67. fi
  68. fi
  69. ### End z Jump Around ### }}}
  70. ### MOTD Stuff ### {{{
  71. ### Fortune At Login ### {{{
  72. ## Tests for fortune, root, interactive shell, and dumb term
  73. if [ $(command -v fortune) ] && [ ${UID} != '0' ] && [[ $- == *i* ]] && [ ${TERM} != 'dumb' ]; then
  74. fortune -a
  75. else
  76. MISSING_ITEMS+="fortune, "
  77. fi
  78. ### End Fortune ### }}}
  79. ### Memo At Login ### {{{
  80. ## Tests for memo, root, interactive shell, and dumb term
  81. # http://www.getmemo.org/index.html
  82. if [ $(command -v memo) ] && [ ${UID} != '0' ] && [[ $- == *i* ]] && [ ${TERM} != 'dumb' ]; then
  83. ## If it has been four or more hours, show.
  84. if [ -e ${HOME}/.memo ] && [ "$(date +%s)" -ge "$(echo $(stat --printf=%Y ${HOME}/.memo) + 14400 | bc)" ]; then
  85. memo -u 2>/dev/null
  86. touch ${HOME}/.memo
  87. fi
  88. else
  89. MISSING_ITEMS+="memo, "
  90. fi
  91. ### End Memo ### }}}
  92. ### Taskwarrior At Login ### {{{
  93. ## Tests for task, root, interactive shell, and dumb term
  94. # http://taskwarrior.org/
  95. if [ $(command -v task) ] && [ ${UID} != '0' ] && [[ $- == *i* ]] && [ ${TERM} != 'dumb' ]; then
  96. ## Don't try to show if term is too small
  97. if [ $(tput cols) -ge 90 ]; then
  98. ## If it has been four or more hours, show.
  99. if [ -e ${HOME}/.task/pending.data ] && [ "$(date +%s)" -ge "$(echo $(stat --printf=%Y ${HOME}/.task/pending.data) + 14400 | bc)" ]; then
  100. task limit:5 2>/dev/null
  101. touch ${HOME}/.task/pending.data
  102. fi
  103. fi
  104. else
  105. MISSING_ITEMS+="taskwarrior, "
  106. fi
  107. ### End Taskwarrior ### }}}
  108. ### End MOTD Stuff ### }}}
  109. ### Game Confs ### {{{
  110. ### Nethack Conf ### {{{
  111. if [ -f ${HOME}/.nethackrc ]; then
  112. export NETHACKOPTIONS=~/.nethackrc
  113. else
  114. MISSING_ITEMS+="nethackrc, "
  115. fi
  116. ### End Nethack ### }}}
  117. ### Slash'em Conf ### {{{
  118. if [ -f ${HOME}/.slashemrc ]; then
  119. export SLASHEMOPTIONS=~/.slashemrc
  120. else
  121. MISSING_ITEMS+="slashemrc, "
  122. fi
  123. ### End Slash'em ### }}}
  124. ### End Game Confs ### }}}
  125. ### Figlet Fonts ### {{{
  126. if [ -d "${HOME}/.config/figfonts" ]; then
  127. export FIGLET_FONTDIR="${HOME}/.config/figfonts"
  128. fi
  129. ### End Figlet Fonts ### }}}
  130. ### Ensure Unicode ### {{{
  131. if [ -z "${LANG}" ]; then
  132. export LANG="en_US.UTF-8"
  133. fi
  134. if [ -z "${LANGUAGE}" ]; then
  135. export LANGUAGE="en_US.UTF-8"
  136. fi
  137. ### Ensure Unicode ### }}}
  138. ## This section is here for reminding people why you shouldn't force the TERM
  139. # ### TERM color ### {{{
  140. # ## Disabled, as forcing is kind of bad >_>
  141. # ## http://blog.sanctum.geek.nz/term-strings/
  142. # if [ -e /usr/share/terminfo/x/xterm-256color ]; then
  143. # export TERM='xterm-256color'
  144. # else
  145. # export TERM='xterm-color'
  146. # fi
  147. # ### End TERM ### }}}