bashrc-all 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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 2> /dev/null)
  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=xterm-color emacsclient $1 &
  60. export EDITOR="emacsclient -c"
  61. elif [[ "$(ps aux | grep -v grep | grep kate)" ]];
  62. then
  63. kate $1
  64. export EDITOR="kate"
  65. elif [[ "$(ps aux | grep -v grep | grep code-oss)" ]];
  66. then
  67. code-oss $1
  68. export EDITOR="code-oss"
  69. else
  70. VIM_PATH=$(which vim)
  71. $VIM_PATH $1
  72. export EDITOR=$VIM_PATH
  73. fi
  74. }
  75. # HN Helper functions
  76. # Pull up comments for number
  77. export HN_PATH=$(which hn 2> /dev/null)
  78. hnc() {
  79. if [ ! -z "$HN_PATH" ]; then
  80. hn view -c $1 | less -r
  81. else
  82. echo "hn not in path"
  83. fi
  84. }
  85. export HIMALAYA_PATH=$(which himalaya 2> /dev/null)
  86. if [ ! -z $HIMALAYA_PATH ]; then
  87. . ~/Repos/dotfiles/himalaya/himalaya_shell_ui.sh
  88. fi
  89. if which docker > /dev/null; then
  90. alias dpa="echo \"docker ps --all\" ; docker ps --all"
  91. fi
  92. # GPG Decrypt wrapper
  93. export GPG_PATH=$(which gpg)
  94. if [ ! -z $GPG_PATH ]; then
  95. function encrypt() {
  96. if [ -z $1 ]; then
  97. echo "Must pass path to this function"
  98. return 1
  99. fi
  100. gpg -c --armor --cipher-algo AES256 --no-symkey-cache --output $1.asc $1
  101. }
  102. function decrypt() {
  103. if [ -z $1 ]; then
  104. echo "Must pass path to this function"
  105. return 1
  106. fi
  107. gpg --no-symkey-cache -d $1
  108. }
  109. fi
  110. alias open-ssh="ps aux | awk '{if (\$11 ~ /ssh$/) { print substr(\$0, index(\$0,\$9)) }}'"
  111. alias reload="source ~/.bashrc"
  112. pb () {
  113. curl -F "file=@-" http://chate.io:669
  114. }
  115. ckgit () {
  116. if [ ! -z $1 ]; then
  117. DIR=$1
  118. else
  119. DIR="$HOME/Repos"
  120. fi
  121. GIT_PATH=$(which git);
  122. for dirp in $($EXA_PATH -d $DIR/*/); do
  123. if [[ -d "$dirp/.git" ]]; then
  124. RET=$($GIT_PATH -C $dirp status --porcelain)
  125. if [[ ! -z "$RET" ]]; then
  126. echo "* $dirp"
  127. echo "$RET"
  128. echo ""
  129. fi
  130. fi
  131. done
  132. }
  133. # For use with emacs vterm
  134. # See: https://github.com/akermu/emacs-libvterm
  135. vterm_printf(){
  136. if [ -n "$TMUX" ] && ([ "${TERM%%-*}" = "tmux" ] || [ "${TERM%%-*}" = "screen" ] ); then
  137. # Tell tmux to pass the escape sequences through
  138. printf "\ePtmux;\e\e]%s\007\e\\" "$1"
  139. elif [ "${TERM%%-*}" = "screen" ]; then
  140. # GNU screen (screen, screen-256color, screen-256color-bce)
  141. printf "\eP\e]%s\007\e\\" "$1"
  142. else
  143. printf "\e]%s\e\\" "$1"
  144. fi
  145. }
  146. if [[ "$INSIDE_EMACS" = 'vterm' ]]; then
  147. function clear(){
  148. vterm_printf "51;Evterm-clear-scrollback";
  149. tput clear;
  150. }
  151. fi
  152. alias spesktv='mpv http://chate.io:55555'
  153. if [ -f "$HOME/.openai-key" ]; then
  154. source "$HOME/.openai-key"
  155. fi
  156. # Case defines platform specific configs
  157. # Platform agnostic configs above
  158. case $(cat /etc/hostname) in
  159. Simons-MacBook-Pro.local)
  160. export PS1="\w λ > \[$(tput sgr0)\]"
  161. # Mac aliases
  162. alias shorten-ps1="PS1='λ > '"
  163. alias default-ps1='PS1="\w λ > \[$(tput sgr0)\]"'
  164. alias emacs="/Applications/Emacs.app/Contents/MacOS/Emacs"
  165. # PATH setups
  166. 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'
  167. default-ps1
  168. clear
  169. echo "Loaded MacM1 config"
  170. ;;
  171. swatson-casana)
  172. export TERM=xterm-256color # This fixes some vim issues
  173. export PS1="\[\033[36m\]\w\[\033[m\] λ "
  174. # function to set terminal title
  175. function set-title() {
  176. if [[ -z "$ORIG" ]]; then
  177. ORIG=$PS1
  178. fi
  179. TITLE="\[\e]2;$*\a\]"
  180. PS1=${ORIG}${TITLE}
  181. }
  182. alias ssh-old="ssh -oKexAlgorithms=+diffie-hellman-group1-sha1"
  183. alias sleep-open="sudo zzz && slock"
  184. alias ssh-aws="ssh -i ~/.ssh/aws_key"
  185. tmux_init () {
  186. $TMUX_PATH new -s services -d
  187. $TMUX_PATH new -s admin -d
  188. $TMUX_PATH new -s personal -d
  189. $TMUX_PATH new -s music -d
  190. $TMUX_PATH new -s lisp-koans -d
  191. $TMUX_PATH new -s emacs -d
  192. }
  193. # Load non tracked aliases for work specific things
  194. source ~/Work/secure_shell_aliases
  195. # Since moving to KDE, my default shell session starts me in / ?
  196. cd
  197. echo "Loaded Void Work Config"
  198. ;;
  199. void)
  200. export PS1="\[\033[36m\]\w\[\033[m\] λ "
  201. alias shorten-ps1="PS1='λ > '"
  202. echo "Loaded Void config"
  203. ;;
  204. m1nix)
  205. export PS1="\[\033[36m\]\w\[\033[m\] λ "
  206. alias shorten-ps1="PS1='λ > '"
  207. echo "Loaded m1nix config"
  208. esac