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