bashrc-all 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. if [ -f ~/.wal_alias ]; then
  2. . ~/.wal_alias
  3. fi
  4. [ -f ~/.fzf.bash ] && source ~/.fzf.bash
  5. # Cargo config
  6. [ -f ~/.cargo ] && source "$HOME/.cargo/env"
  7. CAT_PATH=$(which cat --skip-alias)
  8. if [ -f ~/.cache/wal/sequences ]; then
  9. $CAT_PATH ~/.cache/wal/sequences
  10. fi
  11. export EDITOR=$(which vim)
  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. if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
  40. then
  41. PATH="$HOME/.local/bin:$HOME/bin:$PATH"
  42. fi
  43. export PATH
  44. # HN Helper functions
  45. # Pull up comments for number
  46. export HN_PATH=$(which hn)
  47. hnc() {
  48. if [ ! -z "$HN_PATH" ]; then
  49. hn view -c $1 | less -r
  50. else
  51. echo "hn not in path"
  52. fi
  53. }
  54. export HIMALAYA_PATH=$(which himalaya)
  55. if [ ! -z $HIMALAYA_PATH ]; then
  56. . ~/Repos/dotfiles/himalaya/himalaya_shell_ui.sh
  57. fi
  58. # GPG Decrypt wrapper
  59. export GPG_PATH=$(which gpg)
  60. if [ ! -z $GPG_PATH ]; then
  61. function encrypt() {
  62. if [ -z $1 ]; then
  63. echo "Must pass path to this function"
  64. return 1
  65. fi
  66. gpg -c --armor --cipher-algo AES256 --no-symkey-cache --output $1.asc $1
  67. }
  68. function decrypt() {
  69. if [ -z $1 ]; then
  70. echo "Must pass path to this function"
  71. return 1
  72. fi
  73. gpg --no-symkey-cache -d $1
  74. }
  75. fi
  76. alias open-ssh="ps aux | awk '{if (\$11 ~ /ssh$/) { print substr(\$0, index(\$0,\$9)) }}'"
  77. alias reload="source ~/.bashrc"
  78. pb () {
  79. curl -F "file=@-" http://chate.io:669
  80. }
  81. ckgit () {
  82. if [ ! -z $1 ]; then
  83. DIR=$1
  84. else
  85. DIR="$HOME/Repos"
  86. fi
  87. GIT_PATH=$(which git);
  88. for dirp in $($EXA_PATH -d $DIR/*/); do
  89. if [[ -d "$dirp/.git" ]]; then
  90. RET=$($GIT_PATH -C $dirp status --porcelain)
  91. if [[ ! -z "$RET" ]]; then
  92. echo "* $dirp"
  93. echo "$RET"
  94. echo ""
  95. fi
  96. fi
  97. done
  98. }
  99. # For use with emacs vterm
  100. # See: https://github.com/akermu/emacs-libvterm
  101. vterm_printf(){
  102. if [ -n "$TMUX" ] && ([ "${TERM%%-*}" = "tmux" ] || [ "${TERM%%-*}" = "screen" ] ); then
  103. # Tell tmux to pass the escape sequences through
  104. printf "\ePtmux;\e\e]%s\007\e\\" "$1"
  105. elif [ "${TERM%%-*}" = "screen" ]; then
  106. # GNU screen (screen, screen-256color, screen-256color-bce)
  107. printf "\eP\e]%s\007\e\\" "$1"
  108. else
  109. printf "\e]%s\e\\" "$1"
  110. fi
  111. }
  112. if [[ "$INSIDE_EMACS" = 'vterm' ]]; then
  113. function clear(){
  114. vterm_printf "51;Evterm-clear-scrollback";
  115. tput clear;
  116. }
  117. fi
  118. alias spesktv='mpv http://chate.io:55555'
  119. # Case defines platform specific configs
  120. # Platform agnostic configs above
  121. case $(hostname) in
  122. Simons-MacBook-Pro.local)
  123. export PS1="\w λ > \[$(tput sgr0)\]"
  124. # Mac aliases
  125. alias shorten-ps1="PS1='λ > '"
  126. alias default-ps1='PS1="\w λ > \[$(tput sgr0)\]"'
  127. alias emacs="/Applications/Emacs.app/Contents/MacOS/Emacs"
  128. # PATH setups
  129. 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'
  130. default-ps1
  131. clear
  132. echo "Loaded MacM1 config"
  133. ;;
  134. swatson-casana)
  135. export TERM=xterm-256color # This fixes some vim issues
  136. export PS1="\[\033[36m\]\w\[\033[m\] λ "
  137. # function to set terminal title
  138. function set-title() {
  139. if [[ -z "$ORIG" ]]; then
  140. ORIG=$PS1
  141. fi
  142. TITLE="\[\e]2;$*\a\]"
  143. PS1=${ORIG}${TITLE}
  144. }
  145. alias ssh-old="ssh -oKexAlgorithms=+diffie-hellman-group1-sha1"
  146. alias sleep-open="sudo zzz && slock"
  147. alias ssh-aws="ssh -i ~/.ssh/aws_key"
  148. tmux_init () {
  149. $TMUX_PATH new -s services -d
  150. $TMUX_PATH new -s admin -d
  151. $TMUX_PATH new -s personal -d
  152. $TMUX_PATH new -s music -d
  153. $TMUX_PATH new -s lisp-koans -d
  154. $TMUX_PATH new -s emacs -d
  155. }
  156. # Load non tracked aliases for work specific things
  157. source ~/Work/secure_shell_aliases
  158. echo "Loaded Void Work Config"
  159. ;;
  160. void)
  161. export PS1="\[\033[36m\]\w\[\033[m\] λ "
  162. alias shorten-ps1="PS1='λ > '"
  163. echo "Loaded Void config"
  164. esac