URI:
       .bashrc - dotfiles - dark dots
  HTML git clone https://git.drkhsh.at/dotfiles
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
       .bashrc (3950B)
       ---
            1 # ██████╗  █████╗ ███████╗██╗  ██╗██████╗  ██████╗
            2 # ██╔══██╗██╔══██╗██╔════╝██║  ██║██╔══██╗██╔════╝
            3 # ██████╔╝███████║███████╗███████║██████╔╝██║
            4 # ██╔══██╗██╔══██║╚════██║██╔══██║██╔══██╗██║
            5 # ██████╔╝██║  ██║███████║██║  ██║██║  ██║╚██████╗
            6 # ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝
            7 #                          drkhsh <me@drkhsh.at>
            8 
            9 # helpers
           10 _exists() {
           11         type $1 > /dev/null 2>&1
           12 }
           13 
           14 # history
           15 test -d $HOME/.local/state/bash || mkdir -p $HOME/.local/state/bash
           16 HISTSIZE=10000
           17 HISTFILE=~/.local/state/bash/history
           18 shopt -s histappend
           19 PROMPT_COMMAND='history -a' # save hist immediately
           20 export HISTCONTROL=ignorespace:ignoredups
           21 
           22 # i'm lazy
           23 alias mkdir="mkdir -p"
           24 alias df="df -h"
           25 alias du="du -h"
           26 alias cp="cp -r"
           27 alias scp="scp -r"
           28 alias ..='cd ..'
           29 alias ...='cd ../..'
           30 alias :q='exit'
           31 alias "cd.."="cd .."
           32 
           33 # colors
           34 export CLICOLOR=1
           35 alias ls="ls --color -Fh --group-directories-first"
           36 alias grep="grep --color=always"
           37 
           38 # compatibility
           39 _exists vim && alias vi="vim"
           40 _exists nvim && alias vim="nvim" && alias vi="nvim"
           41 _exists sudo && alias doas="sudo "
           42 _exists bc && alias bc="bc -lq"
           43 ! _exists stow && _exists stash && alias stow="stash"
           44 ! _exists ping6 && alias ping6="ping -6"
           45 
           46 # clean home
           47 alias wget='wget --no-hsts' # remove ~/.wget-hsts
           48 
           49 # pager
           50 if _exists less; then
           51        PAGER=less
           52        LESSHISTFILE=-
           53        # -I  ignore case
           54        # -R  colored output
           55        # -X  don't clear on exit
           56        # -Ps string prompt
           57        LESS='-IRXPs %lt-%lb (%Pt-%Pb \%) ░ %bt-%bbb ░ %f ░▒▓'
           58        export PAGER LESSHISTFILE LESS
           59 fi
           60 export MANWIDTH=80
           61 
           62 # editor
           63 _exists vim && EDITOR=vim
           64 _exists nvim && EDITOR=nvim
           65 VISUAL=$EDITOR
           66 export EDITOR VISUAL
           67 
           68 # no mosh titles
           69 export MOSH_TITLE_NOPREFIX=1
           70 
           71 # xdg base directories
           72 export XDG_CONFIG_HOME="$HOME"/.config
           73 export PACKAGE_MANAGER_HOME="$HOME"/.local/lib
           74 export XDG_DATA_HOME="$HOME"/.local/share
           75 export XDG_CACHE_HOME="$HOME"/.local/cache
           76 export XDG_STATE_HOME="$HOME"/.local/state
           77 export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:=/tmp}"
           78 
           79 # clean home
           80 export CARGO_HOME="$PACKAGE_MANAGER_HOME"/cargo
           81 export RUSTUP_HOME="$PACKAGE_MANAGER_HOME"/rustup
           82 export GOPATH="$PACKAGE_MANAGER_HOME"/go
           83 export GOMODCACHE="$XDG_CACHE_HOME"/go/mod
           84 export GNUPGHOME="$XDG_DATA_HOME"/gpg
           85 export KUBECONFIG="$XDG_CONFIG_HOME"/kube/config
           86 export KUBECACHEDIR="$XDG_RUNTIME_DIR"/kube
           87 export K9SCONFIG="$XDG_CONFIG_HOME"/k9s
           88 export MINIKUBE_HOME="$XDG_DATA_HOME"/minikube
           89 export SQLITE_HISTORY=$XDG_DATA_HOME/sqlite_history
           90 export DOCKER_CONFIG="$XDG_CONFIG_HOME"/docker
           91 export PYTHON_HISTORY=$XDG_STATE_HOME/python/history
           92 export PYTHONPYCACHEPREFIX=$XDG_CACHE_HOME/python
           93 export PYTHONUSERBASE=$XDG_DATA_HOME/python
           94 export W3M_DIR="$XDG_STATE_HOME/w3m"
           95 export WGETRC="$XDG_CONFIG_HOME/wgetrc"
           96 
           97 # include user PATH
           98 [ -d "$HOME/bin" ] && export PATH="$HOME/bin:$PATH"
           99 [ -d "$HOME/.local/bin" ] && export PATH="$HOME/.local/bin:$PATH"
          100 
          101 # systemd
          102 _exists systemctl && export SYSTEMD_PAGER=
          103 
          104 # kubernetes
          105 _exists kubectl && source <(kubectl completion bash)
          106 
          107 # include cargo/go path if necessary
          108 _exists cargo && export PATH=$PATH:$HOME/.local/lib/cargo/bin
          109 _exists go && export PATH=$PATH:$HOME/.local/lib/go/bin
          110 
          111 # prompt
          112 export PS1="\[$(tput setaf 165)\]\u\[$(tput setaf 14)\]@\[$(tput setaf 224)\]\h\[$(tput setaf 14)\]:\[$(tput setaf 39)\]\w\[$(tput sgr0)\]$ "
          113 
          114 # machine-specific bashrc
          115 if [[ -f ~/.bashrc.local ]]; then
          116         source ~/.bashrc.local
          117 fi
          118 
          119 # undefine helpers
          120 unset -f _exists