citadel

My dotfiles, scripts and nix configs
git clone git://jb55.com/citadel
Log | Files | Refs | README | LICENSE

.bash_aliases (5398B)


      1 #!/usr/bin/env bash
      2 # generic stuff for non-interactive shells
      3 
      4 # sharefile
      5 export PAGER="less"
      6 export LESS="-cix8RM --save-marks"
      7 
      8 # mesa
      9 export RADV_PERFTEST=aco
     10 export AMD_DEBUG=nodma
     11 
     12 TERM_THEME="$(basename $(readlink ~/.Xresources.d/themes/current))"
     13 
     14 if [ "$TERM_THEME" == "light" ]
     15 then
     16 	export BAT_THEME=GitHub
     17 else
     18 	export BAT_THEME=base16
     19 fi
     20 
     21 export NNCPCFG=~/.nncprc
     22 export PANDOC=pandoc-nice
     23 export BAT_STYLE=plain
     24 export LPASS_HOME="$HOME/.config/lpass"
     25 export FUZZER=fzf
     26 export GOPHERCLIENT=vf1
     27 export GEMINICLIENT=av98
     28 export GOPHER=$GOPHERCLIENT
     29 export GNUPGHOME="$HOME/.gnupg"
     30 export SHAREFILE_HOST='charon:public/s/'
     31 export KINDLE_FROM_EMAIL='jackbox55@gmail.com'
     32 export KINDLE_TXT_EMAIL='jb55@jb55.com'
     33 export KINDLE_EMAIL='jb55@free.kindle.com'
     34 export SHAREFILE_URL='https://jb55.com/s/'
     35 export SHARE_SS_DIR="$HOME/var/img/ss"
     36 export DOTFILES=${DOTFILES:-$HOME/dotfiles}
     37 export VI_MODE=1
     38 export XZ=pxz
     39 export HISTSIZE=50000
     40 export FZF_CTRL_R_OPTS="-e"
     41 export FZF_DEFAULT_OPTS="-e"
     42 export FZF_DEFAULT_COMMAND='rg --files --hidden'
     43 export EMACSCLIENT=edit
     44 
     45 export NIXPKGS=$HOME/nixpkgs
     46 
     47 # nix paths
     48 export NIX_PATH="nixpkgs=$NIXPKGS:$NIX_PATH"
     49 export NIX_PATH="nixos-config=$NIX_FILES:$NIX_PATH"
     50 export NIX_PATH="jb55pkgs=$HOME/etc/jb55pkgs:$NIX_PATH"
     51 export NIX_PATH="dotfiles=$HOME/dotfiles:$NIX_PATH"
     52 
     53 # Customize to your needs...
     54 
     55 # other
     56 export EDITOR="edit"
     57 export VISUAL="edit"
     58 export BROWSER="browser"
     59 export PAGER=less
     60 
     61 # go
     62 
     63 export GOPATH=$HOME/dev/gocode
     64 export PATH=$HOME/bin:$PATH
     65 export PATH=$HOME/.local/bin:$PATH
     66 export PATH=$HOME/.npm/bin:$PATH
     67 
     68 md () {
     69     mandown README*
     70 }
     71 
     72 function run_fuzzer() {
     73 	eval "$(fuzz-run-command "$@")"
     74 }
     75 
     76 alias C="pcal list"
     77 alias m="neomutt"
     78 alias mq="msmtp-queue"
     79 alias s="general-status"
     80 alias t="todo.sh"
     81 alias e="edit -n"
     82 alias g=git
     83 alias f=run_fuzzer
     84 alias vim=nvim
     85 alias feh="feh --conversion-timeout 2"
     86 alias info="info --vi-keys"
     87 alias ag="ag --pager=less"
     88 alias attach="grabssh; screen -rD"
     89 alias awkt="awk -v FS=$'\t' -v OFS=$'\t'"
     90 alias catt="pygmentize -O style=monokai -f console256 -g"
     91 alias clip="xclip -selection clipboard"
     92 alias cpptags="ctags -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++"
     93 alias crontab="VIM_CRONTAB=true crontab"
     94 alias cutt="cut -d $'\t' --output-delimiter=$'\t'"
     95 alias emacs="env TERM=xterm-256color emacs"
     96 alias fixssh="source $HOME/bin/fixssh"
     97 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'"
     98 alias jsonpp="python -mjson.tool"
     99 alias ls="ls --color"
    100 alias noder="env NODE_NO_READLINE=1 rlwrap node"
    101 alias nr="npm run"
    102 alias page=$PAGER
    103 alias prettyjson=jsonpp
    104 alias sorry='sudo $(fc -l -n -1)'
    105 alias tmuxa="tmux a -d -t "
    106 alias tmux="tmux -2"
    107 alias vless="/usr/share/vim/vim72/macros/less.sh"
    108 alias vnc_once="x11vnc -safer -nopw -once -display :0"
    109 alias wget="wget -c"
    110 alias xclip="xclip -selection clipboard"
    111 alias myip="dig +short myip.opendns.com @resolver1.opendns.com"
    112 alias wanip=myip
    113 alias myipaddress=myip
    114 alias ns="nix-shell -p"
    115 alias fzf="fzf --exact"
    116 alias u="cd .."
    117 alias scs="systemctl status"
    118 alias scsu="systemctl status --user"
    119 alias jc="journalctl -u"
    120 alias jcu="journalctl --user -u"
    121 
    122 ghclone () {
    123   cd "$(gh-clone "$@")"
    124 }
    125 
    126 srhtclone () {
    127   cd "$(srht-clone "$@")"
    128 }
    129 
    130 cdnp () {
    131   nix-build '<nixpkgs>' --no-out-link -A "$1"
    132   cd $(nix-path "$1")
    133 }
    134 
    135 np () {
    136   nix-path "$1"
    137 }
    138 
    139 nsr () {
    140   local cmd="$1"
    141   shift
    142   nix-shell -p "$cmd" --run "$@"
    143 }
    144 
    145 nsr2 () {
    146     local cmd="$1"
    147     shift
    148     local cmd2="$(<<<"$cmd" rev | cut -d. -f1 | rev) $@"
    149     nsr "$cmd" "$cmd2"
    150 }
    151 
    152 nsc () {
    153   local cmd="$1"
    154   shift
    155   nix-shell -p "$cmd" --command "$@"
    156 }
    157 
    158 share () {
    159   sharefile "$@" | xclip
    160 }
    161 
    162 sharess () {
    163   share_last_ss | xclip
    164 }
    165 
    166 lt () {
    167   ls -ltah "$@" | "$PAGER"
    168 }
    169 
    170 lt1 () {
    171   res=$(\ls -1 -t "$@" | head -n1)
    172   xclip <<<"$res"
    173   printf '%s\n' "$res"
    174 }
    175 
    176 mv1 () {
    177   mv $(lt1 | stripansi) "$@"
    178 }
    179 
    180 pcsv () {
    181   csv-delim "$@" | pcsvt
    182 }
    183 
    184 pcsvt () {
    185   columnt "$@" | cat -n | less -R -S
    186 }
    187 
    188 header() {
    189   headers "${2:-/dev/stdin}" | grep "$1" | cutt -f1 | sed -E 's,^[ ]*,,g'
    190 }
    191 
    192 nsum() {
    193   awkt '{total = total + $1}END{print total}'
    194 }
    195 
    196 sumcol() {
    197   cut -f "$1" | nsum
    198 }
    199 
    200 uniqc() {
    201   sort "$@" | uniq -c | sort -nr
    202 }
    203 
    204 cdl () {
    205   cd "$(dirname "$(readlink -f "$(which "$1")")")"
    206 }
    207 
    208 env-type () {
    209   envtype="$1"
    210   shift
    211   nix-shell -Q -p $envtype "$@"
    212 }
    213 
    214 haskell-env () {
    215   env-type "haskellEnv" "$@"
    216 }
    217 
    218 haskell-env-hoogle () {
    219   env-type "haskellEnvHoogle" "$@"
    220 }
    221 
    222 haskell-env-tools() {
    223   env-type "haskellTools" "$@"
    224 }
    225 
    226 build-nix-cache() {
    227   nix-env -f "$NIXPKGS" -qaP \* > ~/.nixenv.cache
    228 }
    229 
    230 haskell-shell() {
    231   nix-shell -p "haskellPackages.ghcWithPackages (pkgs: with pkgs; [$*])"
    232 }
    233 
    234 nix-path() {
    235   nix-instantiate --eval --expr 'with import <nixpkgs> {}; "${'"$1"'}"' | sed 's/"//g'
    236 }
    237 
    238 vnc-once() {
    239   x11vnc -safer -nopw -once -display ':0' "$1"
    240 }
    241 
    242 sql_wineparty() {
    243   export CS='postgres://wineparty.xyz/wineparty'
    244   export PG_USER='jb55'
    245 }
    246 
    247 sql_() {
    248   local query="$1"
    249   local args=("-U" "$pg_user" -A)
    250   if [ ! -z "$query" ];
    251   then
    252     args+=(-c "$query")
    253   fi
    254   psql -F $'\t' "${args[@]}"
    255 }
    256 
    257 sql() {
    258   sql_ "$@" -t | pcsvt
    259 }
    260 
    261 # fzf
    262 source $DOTFILES/.fzf_helpers
    263 
    264 # z
    265 source $HOME/bin/z.sh
    266 
    267 # private stuff
    268 source $HOME/.bash_private
    269 
    270 # nix
    271 #. /Users/jb55/.nix-profile/etc/profile.d/nix.sh
    272 
    273 CURL_CA_BUNDLE=/opt/local/share/curl/curl-ca-bundle.crt