bashrc-all 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. # -*- shell-script-mode -*-
  2. if [ -f ~/.wal_alias ]; then
  3. . ~/.wal_alias
  4. fi
  5. [ -f ~/.fzf.bash ] && source ~/.fzf.bash
  6. # Cargo config
  7. [ -f ~/.cargo ] && source "$HOME/.cargo/env"
  8. CAT_PATH=$(which cat --skip-alias)
  9. if [ -f ~/.cache/wal/sequences ]; then
  10. $CAT_PATH ~/.cache/wal/sequences
  11. fi
  12. BPYTOP_PATH=$(which bpytop)
  13. BTOP_PATH=$(which btop)
  14. if [ ! -z "$BPYTOP_PATH" ] && [ -z $BTOP_PATH ]; then
  15. alias htop="bpytop -b \"cpu mem net proc\""
  16. elif [ ! -z "$BTOP_PATH" ] && [ -z $BPYTOP_PATH ]; then
  17. alias htop="btop"
  18. elif [ ! -z "$BTOP_PATH" ] && [ ! -z $BPYTOP_PATH ]; then
  19. alias htop="btop"
  20. fi
  21. EXA_PATH=$(which exa)
  22. if [ ! -z "$EXA_PATH" ]; then
  23. alias ls="$EXA_PATH"
  24. alias ll="$EXA_PATH -lahg"
  25. alias lg="$EXA_PATH -lahg --git"
  26. fi
  27. BAT_PATH=$(which bat)
  28. if [ ! -z "$BAT_PATH" ]; then
  29. export MANPAGER="$BAT_PATH --color never"
  30. alias cat="$BAT_PATH --color never"
  31. fi
  32. # Platform agnostic aliases
  33. export TMUX_PATH=$(which tmux --skip-alias)
  34. alias tmuxn="$TMUX_PATH new -s $1"
  35. alias tmuxa="$TMUX_PATH attach -t $1"
  36. alias tmuxl="$TMUX_PATH ls"
  37. alias tmuxq="echo $TMUX"
  38. alias httpserver="python -m SimpleHTTPServer"
  39. # Include .local/bin
  40. if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
  41. then
  42. PATH="$HOME/.local/bin:$HOME/bin:$PATH"
  43. fi
  44. export PATH
  45. # Include roswell
  46. if ! [[ "$PATH" =~ "$HOME/.roswell/bin" ]];
  47. then
  48. if [[ -d "$HOME/.roswell/bin" ]];
  49. then
  50. PATH="$HOME/.roswell/bin:$PATH"
  51. fi
  52. fi
  53. # Stop myself from opening vim when I mean to open emacs on the term
  54. vim()
  55. {
  56. if [[ $(ps aux | grep -v grep | grep emacs) ]];
  57. then
  58. # using anemic term/color/etc as it's faster in emacs
  59. TERM=tmux emacsclient -nw $1
  60. export EDITOR="emacsclient"
  61. else
  62. VIM_PATH=$(which vim)
  63. $VIM_PATH $1
  64. export EDITOR=$VIM_PATH
  65. fi
  66. }
  67. # HN Helper functions
  68. # Pull up comments for number
  69. export HN_PATH=$(which hn)
  70. hnc() {
  71. if [ ! -z "$HN_PATH" ]; then
  72. hn view -c $1 | less -r
  73. else
  74. echo "hn not in path"
  75. fi
  76. }
  77. export HIMALAYA_PATH=$(which himalaya)
  78. if [ ! -z $HIMALAYA_PATH ]; then
  79. . ~/Repos/dotfiles/himalaya/himalaya_shell_ui.sh
  80. fi
  81. # GPG Decrypt wrapper
  82. export GPG_PATH=$(which gpg)
  83. if [ ! -z $GPG_PATH ]; then
  84. function encrypt() {
  85. if [ -z $1 ]; then
  86. echo "Must pass path to this function"
  87. return 1
  88. fi
  89. gpg -c --armor --cipher-algo AES256 --no-symkey-cache --output $1.asc $1
  90. }
  91. function decrypt() {
  92. if [ -z $1 ]; then
  93. echo "Must pass path to this function"
  94. return 1
  95. fi
  96. gpg --no-symkey-cache -d $1
  97. }
  98. fi
  99. alias open-ssh="ps aux | awk '{if (\$11 ~ /ssh$/) { print substr(\$0, index(\$0,\$9)) }}'"
  100. alias reload="source ~/.bashrc"
  101. pb () {
  102. curl -F "file=@-" http://chate.io:669
  103. }
  104. ckgit () {
  105. if [ ! -z $1 ]; then
  106. DIR=$1
  107. else
  108. DIR="$HOME/Repos"
  109. fi
  110. GIT_PATH=$(which git);
  111. for dirp in $($EXA_PATH -d $DIR/*/); do
  112. if [[ -d "$dirp/.git" ]]; then
  113. RET=$($GIT_PATH -C $dirp status --porcelain)
  114. if [[ ! -z "$RET" ]]; then
  115. echo "* $dirp"
  116. echo "$RET"
  117. echo ""
  118. fi
  119. fi
  120. done
  121. }
  122. # For use with emacs vterm
  123. # See: https://github.com/akermu/emacs-libvterm
  124. vterm_printf(){
  125. if [ -n "$TMUX" ] && ([ "${TERM%%-*}" = "tmux" ] || [ "${TERM%%-*}" = "screen" ] ); then
  126. # Tell tmux to pass the escape sequences through
  127. printf "\ePtmux;\e\e]%s\007\e\\" "$1"
  128. elif [ "${TERM%%-*}" = "screen" ]; then
  129. # GNU screen (screen, screen-256color, screen-256color-bce)
  130. printf "\eP\e]%s\007\e\\" "$1"
  131. else
  132. printf "\e]%s\e\\" "$1"
  133. fi
  134. }
  135. if [[ "$INSIDE_EMACS" = 'vterm' ]]; then
  136. function clear(){
  137. vterm_printf "51;Evterm-clear-scrollback";
  138. tput clear;
  139. }
  140. fi
  141. alias spesktv='mpv http://chate.io:55555'
  142. # Case defines platform specific configs
  143. # Platform agnostic configs above
  144. case $(hostname) in
  145. Simons-MacBook-Pro.local)
  146. export PS1="\w λ > \[$(tput sgr0)\]"
  147. # Mac aliases
  148. alias shorten-ps1="PS1='λ > '"
  149. alias default-ps1='PS1="\w λ > \[$(tput sgr0)\]"'
  150. alias emacs="/Applications/Emacs.app/Contents/MacOS/Emacs"
  151. # PATH setups
  152. PATH='/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/swatson/.fzf/bin:/Users/swatson/Library/Python/3.8/bin'
  153. default-ps1
  154. clear
  155. echo "Loaded MacM1 config"
  156. ;;
  157. swatson-casana)
  158. export TERM=xterm-256color # This fixes some vim issues
  159. export PS1="\[\033[36m\]\w\[\033[m\] λ "
  160. # function to set terminal title
  161. function set-title() {
  162. if [[ -z "$ORIG" ]]; then
  163. ORIG=$PS1
  164. fi
  165. TITLE="\[\e]2;$*\a\]"
  166. PS1=${ORIG}${TITLE}
  167. }
  168. alias ssh-old="ssh -oKexAlgorithms=+diffie-hellman-group1-sha1"
  169. alias sleep-open="sudo zzz && slock"
  170. alias ssh-aws="ssh -i ~/.ssh/aws_key"
  171. tmux_init () {
  172. $TMUX_PATH new -s services -d
  173. $TMUX_PATH new -s admin -d
  174. $TMUX_PATH new -s personal -d
  175. $TMUX_PATH new -s music -d
  176. $TMUX_PATH new -s lisp-koans -d
  177. $TMUX_PATH new -s emacs -d
  178. }
  179. # Load non tracked aliases for work specific things
  180. source ~/Work/secure_shell_aliases
  181. echo "Loaded Void Work Config"
  182. ;;
  183. void)
  184. export PS1="\[\033[36m\]\w\[\033[m\] λ "
  185. alias shorten-ps1="PS1='λ > '"
  186. echo "Loaded Void config"
  187. esac