.bashrc (3102B)
1 # 2 # ~/.bashrc 3 # 4 5 # If not running interactively, don't do anything 6 [[ $- != *i* ]] && return 7 8 set -o vi 9 10 shopt -s histappend # append to history, don't overwrite it 11 export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND" 12 13 GPG_TTY=$(tty) 14 export GPG_TTY 15 16 export EDITOR=vim 17 18 # requires arc-gtk-theme package 19 export GTK_THEME=Arc-Dark 20 21 lf () { 22 # `command` is needed in case `lfcd` is aliased to `lf` 23 cd "$(command lf -print-last-dir "$@")" 24 } 25 26 # run single ssh-agent and cache keys for x duration 27 if ! pgrep -u "$USER" ssh-agent > /dev/null; then 28 test ! -f "$XDG_RUNTIME_DIR/ssh-agent.env" && touch "$XDG_RUNTIME_DIR/ssh-agent.env" 29 ssh-agent -t 30m > "$XDG_RUNTIME_DIR/ssh-agent.env" 30 fi 31 if [[ ! -f "$SSH_AUTH_SOCK" ]]; then 32 source "$XDG_RUNTIME_DIR/ssh-agent.env" >/dev/null 33 fi 34 35 function ts() { 36 date -d @$1 "+%F %r" 37 } 38 39 function gitbig(){ 40 git rev-list --objects --all | 41 git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | 42 sed -n 's/^blob //p' | 43 sort --numeric-sort --key=2 | 44 cut -c 1-12,41- | 45 $(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest 46 } 47 48 function rssf(){ 49 url="$1"; curl -L -s "$url" | sfeed_web "$url" 50 } 51 52 function findstr(){ 53 grep -Rn . -e "$1" 54 } 55 56 function extract () { 57 case $1 in 58 *.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf "$1";; 59 *.tar.gz|*.tgz) tar xzvf "$1";; 60 *.tar.xz|*.txz) tar xJvf "$1";; 61 *.tar) tar -xvf "$1";; 62 *.zip) unzip "$1";; 63 *.rar) unrar x "$1";; 64 *.7z) 7z x "$1";; 65 *.gz) gzip -dk "$1";; 66 *.gpg) gpg --decrypt-files "$1";; 67 esac 68 } 69 70 function vimis(){ 71 sudo vim $(whereis $1 | cut -d ' ' -f2) 72 } 73 74 function irc(){ 75 username=$1 76 test -z "$username" && echo "Username?" && read username 77 tmux new-session -d -s irc && tmux send-keys -t irc "ii -s irc.libera.chat -n $username" Enter 78 } 79 80 function nkill(){ 81 if [ -n "$1" ]; then 82 for pid in `ps -ef | grep $1 | grep -v $$ | grep -v "grep $1" | tr -s ' ' | cut -f2 -d' '`; do 83 echo "killing pid: $pid" 84 kill -9 "$pid" 85 done 86 fi 87 } 88 89 function leak(){ 90 name="$1" 91 [[ ! -f "$name" ]] && echo "$1 not found in current directory" >&2 && return 1; 92 base="${name%.*}" 93 case "${name##*.}" in 94 "c") 95 gcc -g "$name" -o "$base" 96 ;; 97 "cpp") 98 g++ -g "$name" -o "$base" 99 ;; 100 *) 101 base="$name" 102 ;; 103 esac 104 valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes -s "$base" 105 } 106 107 function cex() { 108 txt=$(mktemp) || exit 1 109 command cex -f "$txt" && cd "$(cat "$txt")" 110 rm "$txt" 111 } 112 113 alias ls='ls --color=auto' 114 alias ll='ls -l' 115 alias weather='curl wttr.in' 116 alias bt='bluetoothctl' 117 alias e='cex' 118 alias wifi='nmcli radio wifi' 119 alias todo='vim ~/authored/.todo.adoc' 120 alias signal-cli='sh ~/Downloads/signal-cli/signal-cli.sh' 121 alias lg='lazygit' 122 alias rss='export SFEED_URL_FILE="$HOME/.sfeed/urls" && [ -f "$SFEED_URL_FILE" ] || touch "$SFEED_URL_FILE" && sfeed_curses ~/.sfeed/feeds/*' 123 alias rssu='sfeed_update ~/.sfeed/sfeedrc' 124 alias rsse='vim ~/.sfeed/sfeedrc' 125 alias lockcheck='faillock --user $USER' 126 alias lockfree='faillock --user $USER --reset' 127 128 PS1='[\u@\h \W]\$ '