bashrc-all 4.3 KB

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