export 6.0 KB

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