bashrc-all 5.5 KB

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