export 5.7 KB

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