.bashrc (7253B)
1 # ~/.bashrc: executed by bash(1) for non-login shells. 2 # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) 3 # for examples 4 set -o vi 5 6 export LANGUAGE="en_US.UTF-8" 7 export LANG="en_US.UTF-8" 8 export LC_CTYPE="en_US.UTF-8" 9 export NIXPKGS=$HOME/nixpkgs 10 export NIX_PATH="nixpkgs=$NIXPKGS:$NIX_PATH" 11 export NIX_PATH="nixos-config=$NIX_FILES:$NIX_PATH" 12 export NIX_PATH="jb55pkgs=$HOME/etc/jb55pkgs:$NIX_PATH" 13 export NIX_PATH="dotfiles=$HOME/dotfiles:$NIX_PATH" 14 15 # If not running interactively, don't do anything 16 #[ -z "$PS1" ] && return 17 18 export HOST=$(hostname) 19 export IGNORE_WINDOW_CHECK=1 20 export LONG_RUNNING_COMMAND_TIMEOUT=3 21 IN_NIX="" 22 if [ -n "$IN_NIX_SHELL" ]; then 23 IN_NIX="-nix" 24 fi 25 #export PS1='$(printf "\x01\033[30;1m\x02%3.*s\x01\033[0m\x02 %s%s> \x01\033[33m\x02" $? $? $HOST $IN_NIX)' 26 export PS1='\[\033[30;1m\]$(printf "%3.*s" $? $?)\[\033[0m\] \h\[\033[33m\]> \[\033[0m\]' 27 #export PS0='\033[0m' 28 29 #export PS1='$(printf "\x01\033[30;1m\x02%3.*s\x01\033[0m\x02> " $? $?)' 30 31 # don't put duplicate lines in the history. See bash(1) for more options 32 #export HISTCONTROL=ignoredups 33 # ... and ignore same sucessive entries. 34 export HISTCONTROL=erasedups 35 export HISTSIZE=50000 36 37 # check the window size after each command and, if necessary, 38 # update the values of LINES and COLUMNS. 39 shopt -s checkwinsize 40 41 # OMG 42 shopt -s histappend 43 44 DIRCOLORS="$HOME/.dircolors" 45 UNDISTRACT="$HOME/dotfiles/bash-undistract-me/undistract-me.sh" 46 47 export PAGER="less" 48 export LESS="-cix8RM --save-marks" 49 50 TERM_THEME="dark" 51 if [ -f ~/.Xresources.d/themes/current ]; then 52 TERM_THEME="$(basename $(readlink ~/.Xresources.d/themes/current))" 53 fi 54 55 # private stuff 56 . ~/.bash_private 57 58 if [ "$TERM_THEME" == "light" ] 59 then 60 export BAT_THEME=GitHub 61 else 62 export BAT_THEME=zenburn 63 fi 64 65 export NNCPCFG=~/.nncprc 66 export PANDOC=pandoc-nice 67 export MAIL=/home/jb55/var/notify/email-notify 68 export MAILREADER=/run/current-system/sw/bin/neomutt 69 export BAT_STYLE=plain 70 export LPASS_HOME="$HOME/.config/lpass" 71 export FUZZER=fzf 72 export GOPHERCLIENT=vf1 73 export GEMINICLIENT=av98 74 export GOPHER=$GOPHERCLIENT 75 export GNUPGHOME="$HOME/.gnupg" 76 export SHAREFILE_HOST='charon:/www/cdn.jb55.com/s/' 77 export SHAREFILE_URL='https://cdn.jb55.com/s/' 78 export SHARE_SS_DIR="$HOME/var/img/ss" 79 export DOTFILES=${DOTFILES:-$HOME/dotfiles} 80 export VI_MODE=1 81 export XZ=pxz 82 export FZF_CTRL_R_OPTS="-e" 83 export FZF_DEFAULT_OPTS="-e" 84 export FZF_DEFAULT_COMMAND='rg --files --hidden' 85 export EMACSCLIENT=edit 86 87 # other 88 export EDITOR="edit" 89 export VISUAL="edit" 90 export BROWSER="browser" 91 export PAGER=less 92 93 # go 94 95 export GOPATH=$HOME/dev/gocode 96 export PATH=$HOME/bin:$PATH 97 export PATH=$HOME/.local/bin:$PATH 98 export PATH=$HOME/.npm/bin:$PATH 99 export PATH=$HOME/.cargo/bin:$PATH 100 export PATH=$GOPATH/bin:$PATH 101 102 md () { 103 mandown README* 104 } 105 106 function f() { 107 eval "$(fuzz-run-command "$@")" 108 } 109 110 alias ag="ag --pager=less" 111 alias attach="grabssh; screen -rD" 112 alias awkt="awk -v FS=$'\t' -v OFS=$'\t'" 113 alias catt="pygmentize -O style=monokai -f console256 -g" 114 alias Ci="pcal interactive" 115 alias clip="xclip -selection clipboard" 116 alias C="pcal list" 117 alias cpptags="ctags -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++" 118 alias crontab="VIM_CRONTAB=true crontab" 119 alias cutt="cut -d $'\t' --output-delimiter=$'\t'" 120 alias e="edit -n" 121 alias emacs="env TERM=xterm-256color emacs" 122 alias feh="feh --conversion-timeout 2" 123 alias fixssh="source $HOME/bin/fixssh" 124 #alias f=run_fuzzer 125 alias fzf="fzf --exact" 126 alias g=git 127 alias githist="git reflog show | grep '}: commit' | nl | sort -nr | nl | sort -nr | cut --fields=1,3 | sed s/commit://g | sed -e 's/HEAD*@{[0-9]*}://g'" 128 alias ibmgfx="cp437" 129 alias info="info --vi-keys" 130 alias jc="journalctl -u" 131 alias jcu="journalctl --user -u" 132 alias jsonpp="python -mjson.tool" 133 alias ls="ls --color" 134 alias m="neomutt" 135 alias mw="neomutt -f work" 136 alias mq="msmtp-queue" 137 alias mt="f nt query:today" 138 alias myipaddress=myip 139 alias myip="dig +short myip.opendns.com @resolver1.opendns.com" 140 alias noder="env NODE_NO_READLINE=1 rlwrap node" 141 alias nr="npm run" 142 alias ns="nix-shell -p" 143 alias page=$PAGER 144 alias prettyjson=jsonpp 145 alias qud="steam-run ~/.local/share/Steam/steamapps/common/Caves\ of\ Qud/CoQ.x86_64" 146 alias scs="systemctl status" 147 alias scsu="systemctl status --user" 148 alias s="general-status" 149 alias sorry='sudo $(fc -l -n -1)' 150 alias tmuxa="tmux a -d -t " 151 alias tmux="tmux -2" 152 alias t="todo.sh" 153 alias u="cd .." 154 alias vless="/usr/share/vim/vim72/macros/less.sh" 155 alias vnc_once="x11vnc -safer -nopw -once -display :0" 156 alias wanip=myip 157 alias wget="wget -c" 158 alias xclip="xclip -selection clipboard" 159 160 ghclone () { 161 cd "$(gh-clone "$@")" 162 } 163 164 srhtclone () { 165 cd "$(srht-clone "$@")" 166 } 167 168 cdnp () { 169 nix-build '<nixpkgs>' --no-out-link -A "$1" 170 cd $(nix-path "$1") 171 } 172 173 np () { 174 nix-path "$1" 175 } 176 177 nsr () { 178 local cmd="$1" 179 shift 180 nix-shell -p "$cmd" --run "$@" 181 } 182 183 nsr2 () { 184 local cmd="$1" 185 shift 186 local cmd2="$(<<<"$cmd" rev | cut -d. -f1 | rev) $@" 187 nsr "$cmd" "$cmd2" 188 } 189 190 nsc () { 191 local cmd="$1" 192 shift 193 nix-shell -p "$cmd" --command "$@" 194 } 195 196 share () { 197 sharefile "$@" | xclip 198 } 199 200 sharess () { 201 share_last_ss | xclip 202 } 203 204 lt () { 205 ls -ltah "$@" | "$PAGER" 206 } 207 208 lt1 () { 209 res=$(\ls -1 -t "$@" | head -n1) 210 xclip <<<"$res" 211 printf '%s\n' "$res" 212 } 213 214 mv1 () { 215 mv $(lt1 | stripansi) "$@" 216 } 217 218 pcsv () { 219 csv-delim "$@" | pcsvt 220 } 221 222 pcsvt () { 223 columnt "$@" | cat -n | less -R -S 224 } 225 226 header() { 227 headers "${2:-/dev/stdin}" | grep "$1" | cutt -f1 | sed -E 's,^[ ]*,,g' 228 } 229 230 nsum() { 231 awkt '{total = total + $1}END{print total}' 232 } 233 234 sumcol() { 235 cut -f "$1" | nsum 236 } 237 238 uniqc() { 239 sort "$@" | uniq -c | sort -nr 240 } 241 242 cdl () { 243 cd "$(dirname "$(readlink -f "$(which "$1")")")" 244 } 245 246 env-type () { 247 envtype="$1" 248 shift 249 nix-shell -Q -p $envtype "$@" 250 } 251 252 haskell-env () { 253 env-type "haskellEnv" "$@" 254 } 255 256 haskell-env-hoogle () { 257 env-type "haskellEnvHoogle" "$@" 258 } 259 260 haskell-env-tools() { 261 env-type "haskellTools" "$@" 262 } 263 264 build-nix-cache() { 265 nix-env -f "$NIXPKGS" -qaP \* > ~/.nixenv.cache 266 } 267 268 haskell-shell() { 269 nix-shell -p "haskellPackages.ghcWithPackages (pkgs: with pkgs; [$*])" 270 } 271 272 nix-path() { 273 nix-instantiate --eval --expr 'with import <nixpkgs> {}; "${'"$1"'}"' | sed 's/"//g' 274 } 275 276 vnc-once() { 277 x11vnc -safer -nopw -once -display ':0' "$1" 278 } 279 280 sql_wineparty() { 281 export CS='postgres://wineparty.xyz/wineparty' 282 export PG_USER='jb55' 283 } 284 285 sql_() { 286 local query="$1" 287 local args=("-U" "$pg_user" -A) 288 if [ ! -z "$query" ]; 289 then 290 args+=(-c "$query") 291 fi 292 psql -F $'\t' "${args[@]}" 293 } 294 295 sql() { 296 sql_ "$@" -t | pcsvt 297 } 298 299 # fzf 300 source $DOTFILES/.fzf_helpers 301 302 # z 303 source $HOME/bin/z.sh 304 305 [ -e "$DIRCOLORS" ] && eval "$(dircolors -b "$DIRCOLORS")" 306 [ -f ~/.fzf.bash ] && source ~/.fzf.bash 307 [ -f ~/bin/z.sh ] && source ~/bin/z.sh 308 [ -f "$UNDISTRACT" ] && source "$UNDISTRACT" 309 310 eval "$(/run/current-system/sw/bin/direnv hook bash)" 311 312 # needed for the C-h binding 313 bind '"\C-x\C-a": vi-movement-mode' 314 bind '"\C-x\C-e": shell-expand-line' 315 bind '"\C-x\C-r": redraw-current-line' 316 bind '"\C-x^": history-expand-line' 317 318 bind '"\C-f": "`fuzz-run-command`\C-x\C-e"' 319 bind -m vi-command '"\C-f": "i\C-f"' 320 bind '"\C-g": "`fuzz-run-command sh`\C-x\C-e"' 321 bind -m vi-command '"\C-h": "i\C-h"' 322 bind '"\C-e": "!!\C-x\C-e"' 323 bind -m vi-command '"\C-e": "i\C-e"' 324 bind '"\C-l":clear-screen' 325 326