#!/usr/bin/env bash # __________ # ___ ____/_________ __ # __ __/ __ __ \_ | / / # _ /___ _ / / /_ |/ / # /_____/ /_/ /_/_____/ # # XDG thingy export XDG_CONFIG_HOME=$HOME/.config export XDG_CACHE_HOME=$HOME/.cache export XDG_DATA_HOME=$HOME/.local/share export XDG_DATA_DIRS=$HOME/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share # alternate paths export HISTFILE="$XDG_DATA_HOME/bash/bash_history" export BASH_COMPLETION_USER_DIR="$XDG_DATA_HOME/bash" export LESSHISTFILE=- export MOST_INITFILE=$XDG_CONFIG_HOME/mostrc export GTK2_RC_FILES=$XDG_CONFIG_HOME/gtk-2.0/gtkrc export TERMINFO="$XDG_DATA_HOME/terminfo" export TERMINFO_DIRS="$XDG_DATA_HOME/terminfo:/usr/share/terminfo" export GOPATH=$XDG_DATA_HOME/go export GRADLE_USER_HOME=$XDG_DATA_HOME/gradle export _JAVA_OPTIONS=-Djava.util.prefs.userRoot=$XDG_CONFIG_HOME/java export NODE_REPL_HISTORY=$XDG_CACHE_HOME/node_repl_history export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc" export NPM_CONFIG_PREFIX="$XDG_DATA_HOME/npm-global" export CARGO_HOME=$XDG_DATA_HOME/cargo export RUSTUP_HOME=$XDG_DATA_HOME/rustup export BUNDLE_USER_CONFIG=$XDG_CONFIG_HOME/bundle export BUNDLE_USER_CACHE=$XDG_CACHE_HOME/bundle export BUNDLE_USER_PLUGIN=$XDG_DATA_HOME/bundle export GEM_HOME=$XDG_DATA_HOME/gem export GEM_SPEC_CACHE=$XDG_CACHE_HOME/gem export DOCKER_CONFIG=$XDG_CONFIG_HOME/docker export GNUPGHOME=$XDG_DATA_HOME/gnupg export JUPYTER_CONFIG_DIR=$XDG_CONFIG_HOME/jupyter export IPYTHONDIR=$XDG_CONFIG_HOME/ipython export XAUTHORITY=$XDG_RUNTIME_DIR/Xauthority export XINITRC=$XDG_CONFIG_HOME/X11/xinitrc export XSERVERRC=$XDG_CONFIG_HOME/X11/xserverrc # env export PAGER=less export VISUAL=nvim export EDITOR=nvim export SVDIR=$HOME/.local/share/service export _JAVA_AWT_WM_NONREPARENTING=1 export GPG_TTY="$(tty)" # bat export BAT_THEME="base16" # pfetch export PF_INFO="ascii title kernel wm shell uptime pkgs memory" # fzf export FZF_DEFAULT_OPTS="--multi --layout=reverse --inline-info --color fg:#D8DEE9,bg:#2E3440,hl:#A3BE8C,fg+:#D8DEE9,bg+:#434C5E,hl+:#A3BE8C --color pointer:#BF616A,info:#4C566A,spinner:#4C566A,header:#4C566A,prompt:#81A1C1,marker:#EBCB8B" # export FZF_DEFAULT_OPTS="--multi --layout=reverse --inline-info # --color dark # --color fg:-1,bg:-1,hl:#c678dd,fg+:#ffffff,bg+:#4b5263,hl+:#d858fe # --color info:#98c379,prompt:#61afef,pointer:#be5046,marker:#e5c07b,spinner:#61afef,header:#61afef" export FZF_DEFAULT_COMMAND="fd --type f --follow --hidden --exclude .git" export FZF_CTRL_T_OPTS="--no-height --preview-window 'left:60%' --preview '$HOME/.local/bin/garbage/preview {} 2>/dev/null'" export FZF_CTRL_T_COMMAND="fd --follow --hidden --exclude .git" export FZF_ALT_C_OPTS="--preview 'tree -La 1 -C --dirsfirst {} 2>/dev/null'" export FZF_ALT_C_COMMAND="fd --type d --follow --hidden --exclude .git" export FZF_TMUX=1 # ibus export GTK_IM_MODULE=ibus export XMODIFIERS=@im=ibus export QT_IM_MODULE=ibus # qt5ct export QT_QPA_PLATFORMTHEME=qt5ct export QT_PLATFORM_PLUGIN=qt5ct # .NET export DOTNET_CLI_TELEMETRY_OPTOUT=1 # zoxide export _ZO_DATA_DIR="$HOME/.local/share/zoxide" export _ZO_ECHO=1 export _ZO_FZF_OPTS="$FZF_DEFAULT_OPTS --no-multi" export _ZO_RESOLVE_SYMLINKS=1 # z.lua # export _ZL_DATA="$HOME/.local/share/zlua/zlua" # export _ZL_HYPHEN=1 # export _ZL_ECHO=1 # export _ZL_MATCH_MODE=1 # export _ZL_FZF_FLAG="--exact --no-multi" # export _ZL_INT_SORT=1 # export _ZL_ROOT_MARKERS=".git,.svn,.hg,.root,package.json,.projectile,.pro" # export RANGER_ZLUA="$HOME/.local/share/bash/z.lua" # Basher export BASHER_ROOT="$HOME/.local/share/bash/basher" # nodenv export NODENV_ROOT="$HOME/.local/share/nodenv" # pyenv export PYENV_ROOT="$HOME/.local/share/pyenv" # poetry export POETRY_HOME="$HOME/.local/share/poetry" # nnn if command -v nnn >/dev/null then export TERMINAL=alacritty # for the preview script export NNN_PLUG='t:preview-tui;m:nmount;f:fzcd;c:chksum;n:nuke;z:fzz;b:bulknew;d:dups:h:hexview;o:organize;p:pdfview;s:suedit;r:renamer' export NNN_FIFO="/tmp/nnn.fifo" export NNN_ARCHIVE='\\.(7z|a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|rar|rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)$' export NNN_OPENER="$XDG_CONFIG_HOME/nnn/plugins/nuke" export USE_SCOPE=1 export NNN_COLORS='2345' export NNN_FCOLORS='c1e2272e006033f7c6d6abc4' export NNN_BMS="h:~;C:~/Code;D:~/Downloads;P:~/Pictures;V:~/Videos;A:~/Media;U:~/Music;f:~/.config;l:~/.local/share;e:/etc;u:/usr/share;o:/opt;b:/boot;m:/media;M:/mnt;i:/run/media/$USER;v:/var;t:/tmp;d:/dev;s:/srv;r:/;k:/bedrock/strata" export NNN_SSHFS="sshfs -o reconnect,idmap=user,follow_symlinks" fi # lf if command -v lf >/dev/null then export LF_ICONS="\ tw=:\ st=:\ ow=:\ dt=:\ di=:\ fi=:\ ln=:\ or=:\ ex=:\ *.7z=:\ *.a=:\ *.ace=:\ *.alz=:\ *.ai=:\ *.apk=:\ *.arc=:\ *.arj=:\ *.asm=:\ *.asp=:\ *.aup=:\ *.avi=:\ *.awk=:\ *.bash=:\ *.bat=:\ *.bmp=:\ *.bz=:\ *.bz2=:\ *.c=:\ *.c++=:\ *.cab=:\ *.cbr=:\ *.cbz=:\ *.cc=:\ *.class=:\ *.clj=:\ *.cljc=:\ *.cljs=:\ *.cmake=:\ *.cmd=:\ *.coffee=:\ *.conf=:\ *.cp=:\ *.cpio=:\ *.cpp=:\ *.cs=:\ *.csh=:\ *.css=:\ *.cue=:\ *.cvs=:\ *.cxx=:\ *.d=:\ *.dart=:\ *.db=:\ *.deb=:\ *.diff=:\ *.dll=:\ *.doc=:\ *.docx=:\ *.dump=:\ *.dwm=:\ *.dz=:\ *.edn=:\ *.eex=:\ *.efi=:\ *.ejs=:\ *.elf=:\ *.elm=:\ *.epub=:\ *.ear=:\ *.erl=:\ *.esd=:\ *.ex=:\ *.exe=:\ *.exs=:\ *.f#=:\ *.fifo=|:\ *.fish=:\ *.flac=:\ *.flv=:\ *.fs=:\ *.fsi=:\ *.fsscript=:\ *.fsx=:\ *.gem=:\ *.gemspec=:\ *.gif=:\ *.go=:\ *.gz=:\ *.gzip=:\ *.h=:\ *.haml=:\ *.hbs=:\ *.hh=:\ *.hpp=:\ *.hrl=:\ *.hs=:\ *.htaccess=:\ *.htm=:\ *.html=:\ *.htpasswd=:\ *.hxx=:\ *.ico=:\ *.img=:\ *.ini=:\ *.iso=:\ *.jar=:\ *.java=:\ *.jl=:\ *.jpeg=:\ *.jpg=:\ *.js=:\ *.json=:\ *.jsx=:\ *.key=:\ *.ksh=:\ *.leex=:\ *.less=:\ *.lha=:\ *.lhs=:\ *.log=:\ *.lrz=:\ *.lua=:\ *.lz=:\ *.lz4=:\ *.lzh=:\ *.lzma=:\ *.lzo=:\ *.m2v=:\ *.m4a=:\ *.m4v=:\ *.markdown=:\ *.md=:\ *.mdx=:\ *.mjpeg=:\ *.mjpg=:\ *.mjs=:\ *.mkv=:\ *.ml=λ:\ *.mli=λ:\ *.mng=:\ *.mov=:\ *.mp3=:\ *.mp4=:\ *.mp4v=:\ *.mpeg=:\ *.mpg=:\ *.msi=:\ *.mustache=:\ *.nix=:\ *.o=:\ *.odt=:\ *.ods=:\ *.odp=:\ *.ogg=:\ *.pdf=:\ *.php=:\ *.pl=:\ *.pm=:\ *.png=:\ *.pp=:\ *.ppt=:\ *.pptx=:\ *.pro=:\ *.ps1=:\ *.psb=:\ *.pub=:\ *.py=:\ *.pyc=:\ *.pyd=:\ *.pyo=:\ *.r=ﳒ:\ *.rake=:\ *.rar=:\ *.rb=:\ *.rc=:\ *.rlib=:\ *.rmd=:\ *.rom=:\ *.rpm=:\ *.rproj=鉶:\ *.rs=:\ *.rss=:\ *.rtf=:\ *.rz=:\ *.s=:\ *.sar=:\ *.sass=:\ *.scala=:\ *.scss=:\ *.sh=:\ *.slim=:\ *.sln=:\ *.so=:\ *.sql=:\ *.styl=:\ *.suo=:\ *.svg=:\ *.swift=:\ *.swm=:\ *.t=:\ *.t7z=:\ *.tar=:\ *.taz=:\ *.tbz=:\ *.tbz2=:\ *.tex=ﭨ:\ *.tgz=:\ *.tif=:\ *.tiff=:\ *.tlz=:\ *.toml=:\ *.ts=:\ *.tsx=:\ *.txz=:\ *.tz=:\ *.tzo=:\ *.tzst=:\ *.twig=:\ *.vifm=:\ *.vim=:\ *.vimrc=:\ *.vob=:\ *.vue=﵂:\ *.wav=:\ *.war=:\ *.webm=:\ *.webmanifest=:\ *.webp=:\ *.wim=:\ *.xbm=:\ *.xbps=:\ *.xcplayground=:\ *.xhtml=:\ *.xls=:\ *.xlsx=:\ *.xml=:\ *.xpm=:\ *.xul=:\ *.xz=:\ *.yaml=:\ *.yml=:\ *.z=:\ *.zip=:\ *.zoo=:\ *.zsh=:\ *.zip=:\ *.zst=:\ " fi # PATH export PATH=$HOME/.local/bin:$HOME/.local/bin/fzf:$HOME/.local/share/bash/basher/bin:$NODENV_ROOT/bin:$PYENV_ROOT/bin:$POETRY_HOME/bin:$CARGO_HOME/bin:$GOPATH/bin:$NPM_CONFIG_PREFIX/bin:$PATH # _________________ # ___ |__ /__(_)_____ ________ # __ /| |_ /__ /_ __ `/_ ___/ # _ ___ | / _ / / /_/ /_(__ ) # /_/ |_/_/ /_/ \__,_/ /____/ # # remap alias doas="doas --" alias p="pulsemixer" alias ls="exa -lF --icons --sort=type" alias la="exa -laF --icons --sort=type" alias lt="exa --tree" alias cp="cp -vir" alias mv="mv -vi" alias rm="rm -vr" alias mkdir="mkdir -pv" alias no="grep -viP" # alias latest_pkg="expac --timefmt='%Y-%m-%d %T' '%l\t%n' | sort | tail -n 30" alias yarn="yarn --use-yarnrc $XDG_CONFIG_HOME/yarn/config" alias tmux="TERM=screen-256color tmux" alias catc="bat --style plain --color=always" alias startx="startx $HOME/.config/X11/xinitrc" alias fehwpp="feh --no-fehbg --bg-fill --randomize ~/Pictures/Wallpapers/*" # colorizing alias grep="grep --color=auto" alias fgrep="fgrep --color=auto" alias egrep="egrep --color=auto" alias diff="diff --color=auto" alias ncdu="ncdu --color=dark" alias ip="ip -color=always" # vim alias v="nvim" alias vi='nvim -o "$(fzf)"' # emacs alias doom="$HOME/.config/emacs/bin/doom" alias e="emacs -nw" alias em="emacsclient -c -a 'emacs'" # rsync alias rsyncdir="rsync -uavP --delete-after" alias rsyncfile="rsync -avP" # youtube-dl alias yoump3="youtube-dl --extract-audio --audio-format mp3 --embed-thumbnail" alias youflac="youtube-dl --extract-audio --audio-format flac" alias youbest="youtube-dl -f bestvideo+bestaudio" alias youlist="youtube-dl -f bestvideo+bestaudio --yes-playlist" # Lazy cd-ing alias ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..' # colorize man pages man() { LESS_TERMCAP_mb=$'\e[01;31m' \ LESS_TERMCAP_md=$'\e[01;36m' \ LESS_TERMCAP_me=$'\e[0m' \ LESS_TERMCAP_se=$'\e[0m' \ LESS_TERMCAP_so=$'\e[01;44;33m' \ LESS_TERMCAP_ue=$'\e[0m' \ LESS_TERMCAP_us=$'\e[01;32m' \ command man $@ } alias x=extract extract() { local remove_archive local success local extract_dir if (( $# == 0 )); then cat <<-'EOF' >&2 Usage: extract [-option] [file ...] Options: -r, --remove Remove archive after unpacking. EOF fi remove_archive=1 if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then remove_archive=0 shift fi while (( $# > 0 )); do if [[ ! -f "$1" ]]; then echo "extract: '$1' is not a valid file" >&2 shift continue fi success=0 extract_dir="${1:t:r}" case "${1:l}" in *.tar.gz|*.tgz) tar zxvf "$1" ;; *.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; *.tar.xz|*.txz) tar --xz -xvf "$1" || xzcat "$1" | tar xvf - ;; *.tar.zma|*.tlz) tar --lzma -xvf "$1" || lzcat "$1" | tar xvf - ;; *.tar.zst|*.tzst) tar --zstd -xvf "$1" || zstdcat "$1" | tar xvf - ;; *.tar) tar xvf "$1" ;; *.tar.lz) tar xvf "$1" ;; *.tar.lz4) lz4 -c -d "$1" | tar xvf - ;; *.tar.lrz) lrzuntar "$1" ;; *.gz) gunzip -k "$1" ;; *.bz2) bunzip2 "$1" ;; *.xz) unxz "$1" ;; *.lrz) lrunzip "$1" ;; *.lz4) lz4 -d "$1" ;; *.lzma) unlzma "$1" ;; *.z) uncompress "$1" ;; *.zip|*.war|*.jar|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d "$extract_dir" ;; *.rar) unrar x -ad "$1" ;; *.rpm) mkdir "$extract_dir" && cd "$extract_dir" && rpm2cpio "../$1" | cpio --quiet -id && cd .. ;; *.7z) 7za x "$1" ;; *.deb) mkdir -p "$extract_dir/control" mkdir -p "$extract_dir/data" cd "$extract_dir"; ar vx "../${1}" > /dev/null cd control; tar xzvf ../control.tar.gz cd ../data; extract ../data.tar.* cd ..; rm *.tar.* debian-binary cd .. ;; *.zst) unzstd "$1" ;; *) echo "extract: '$1' cannot be extracted" >&2 success=1 ;; esac (( success = $success > 0 ? $success : $? )) (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1" shift done } # update Basher basher_update() { pushd $HOME/.local/share/bash/basher >/dev/null || exit git pull echo -e "\e[01;34mFinished updating Basher\e[0m" popd >/dev/null || exit } # upgrade Basher's packages basherpacks_update() { packages=$(basher list) for pack in $packages do echo -e "\e[01;34mUpgrading $pack\e[0m" basher upgrade "$pack" >/dev/null 2>&1 done } # nnn with cd on quit if command -v nnn >/dev/null; then alias nnn="nnn -Hc" alias ncp="cat ${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} | tr '\0' '\n'" n () { # Block nesting of nnn in subshells if [[ -n $NNNLVL ]] && [ "${NNNLVL:-0}" -ge 1 ]; then echo "nnn is already running" return fi # The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set) # To cd on quit only on ^G, remove the "export" as in: # NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd" # NOTE: NNN_TMPFILE is fixed, should not be modified export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd" # Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn # stty start undef # stty stop undef # stty lwrap undef # stty lnext undef nnn "$@" if [ -f "$NNN_TMPFILE" ]; then . "$NNN_TMPFILE" rm -f "$NNN_TMPFILE" > /dev/null fi } # nnn in dual pane mode (tmux) n2() { tmux new-session -d -s nnn -n nnn "nnn -Hc" tmux split-window -h "nnn -Hc" TERM=screen-256color tmux attach -t nnn:nnn } fi # typing speed testing tt() { iconv -f UTF-8 -t ASCII "$1" | sed 's/--/-/g' \ | sed '/^$/d' | sed 's/^[ \t]*//' | sed 's/\(^.\{1,80\}\).*/\1/' \ > /tmp/tt.txt command tt /tmp/tt.txt } # ________ ______ # ___ __ )_____ __________ /______________ # __ __ | __ `/_ ___/_ __ \ _ \_ ___/ # _ /_/ // /_/ /_(__ )_ / / / __/ / # /_____/ \__,_/ /____/ /_/ /_/\___//_/ # # Install Basher if missing if [[ ! -d $HOME/.local/share/bash/basher ]]; then git clone https://github.com/basherpm/basher.git $HOME/.local/share/bash/basher fi eval "$(basher init - bash)" # Plugins # [[ -d $HOME/.local/share/bash/basher/cellar/packages/kazhala/dotbare ]] || basher install kazhala/dotbare [[ -d $HOME/.local/share/bash/basher/cellar/packages/wfxr/forgit ]] || basher install wfxr/forgit [[ -d $HOME/.local/share/bash/basher/cellar/packages/holman/spark ]] || basher install holman/spark [[ -d $HOME/.local/share/bash/basher/cellar/packages/unixorn/git-extra-commands ]] || basher install unixorn/git-extra-commands # Plugins' init # include kazhala/dotbare dotbare.plugin.bash && _dotbare_completion_cmd include wfxr/forgit forgit.plugin.sh # ________ _______________ # __ ___/______ /__ /___(_)_____________ ________ # _____ \_ _ \ __/ __/_ /__ __ \_ __ `/_ ___/ # ____/ // __/ /_ / /_ _ / _ / / / /_/ /_(__ ) # /____/ \___/\__/ \__/ /_/ /_/ /_/_\__, / /____/ # /____/ # mkdir -p "$BASH_COMPLETION_USER_DIR/completions" # github cli completion if command -v gh >/dev/null && [ ! -f "$BASH_COMPLETION_USER_DIR/completions/gh" ]; then gh completion -s bash > "$BASH_COMPLETION_USER_DIR/completions/gh" fi # kitten from kitty if command -v kitty > /dev/null; then source <(kitty + complete setup bash) fi # Starship prompt if command -v starship > /dev/null; then eval "$(starship init bash --print-full-init)" fi # direnv if command -v direnv >/dev/null ; then eval "$(direnv hook bash)" fi # poetry # if [ ! -d "$POETRY_HOME" ]; then # curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - # fi # if [[ ! -f $BASH_COMPLETION_USER_DIR/completions/poetry ]]; then # poetry completions bash > "$BASH_COMPLETION_USER_DIR/completions/poetry" # fi # pyenv # if [[ ! -d $PYENV_ROOT ]]; then # git clone https://github.com/pyenv/pyenv.git $PYENV_ROOT # git clone https://github.com/pyenv/pyenv-virtualenv.git $PYENV_ROOT/plugins/pyenv-virtualenv # git clone https://github.com/pyenv/pyenv-update.git $PYENV_ROOT/plugins/pyenv-update # fi # eval "$(pyenv init -)" # eval "$(pyenv virtualenv-init -)" # nodenv # if [[ ! -d $NODENV_ROOT ]]; then # git clone https://github.com/nodenv/nodenv.git $NODENV_ROOT # mkdir -p $NODENV_ROOT/plugins # git clone https://github.com/nodenv/node-build.git $NODENV_ROOT/plugins/node-build # git clone https://github.com/nodenv/nodenv-env.git $NODENV_ROOT/plugins/nodenv-env # git clone https://github.com/nodenv/nodenv-man.git $NODENV_ROOT/plugins/nodenv-man # git clone https://github.com/nodenv/nodenv-aliases.git $NODENV_ROOT/plugins/nodenv-aliases # git clone https://github.com/nodenv/nodenv-each.git $NODENV_ROOT/plugins/nodenv-each # git clone https://github.com/nodenv/nodenv-update.git $NODENV_ROOT/plugins/nodenv-update # git clone https://github.com/nodenv/nodenv-vars.git $NODENV_ROOT/plugins/nodenv-vars # fi # eval "$(nodenv init -)" # z.lua # if [[ ! -f "$HOME/.local/share/bash/z.lua" ]]; then # curl -fLo $HOME/.local/share/bash/z.lua https://raw.githubusercontent.com/skywind3000/z.lua/master/z.lua # mkdir -p $HOME/.local/share/zlua # fi # eval "$(lua $HOME/.local/share/bash/z.lua --init bash fzf)" # if command -v ranger >/dev/null; then # if [ ! -f "$HOME/.config/ranger/plugins/ranger_zlua.py" ]; then # curl -fLo $HOME/.config/ranger/plugins/ranger_zlua.py https://github.com/skywind3000/z.lua/raw/master/ranger_zlua.py # chmod 755 $HOME/.config/ranger/plugins/ranger_zlua.py # fi # fi # alias zz='z -c' # restrict matches to subdirs of $PWD # alias zi='z -i' # cd with interactive selection # alias zf='z -I' # use fzf to select in multiple matches # alias zb='z -b' # quickly cd to the parent directory # zoxide if command -v zoxide >/dev/null; then eval "$(zoxide init bash)" if command -v ranger >/dev/null; then if [ ! -f "$HOME/.config/ranger/plugins/ranger_zoxide.py" ]; then curl -fLo $HOME/.config/ranger/plugins/ranger_zoxide.py https://github.com/ajeetdsouza/zoxide/raw/master/contrib/ranger.py chmod 755 $HOME/.config/ranger/plugins/ranger_zoxide.py fi fi fi # autostart gpg-agent at login if ! pgrep -u "$USER" gpg-agent >/dev/null; then gpg-agent --daemon --enable-ssh-support >/dev/null fi if [[ -z "$SSH_AUTH_SOCK" ]]; then export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" fi gpg-connect-agent updatestartuptty /bye >/dev/null # vi mode set -o vi bind 'set show-mode-in-prompt on' bind 'set vi-cmd-mode-string "\e[01;32mN "' bind 'set vi-ins-mode-string "\e[01;32mI "' # ignore upper and lowercase when TAB completion bind "set completion-ignore-case on" # Shell options shopt -s autocd shopt -s cdspell shopt -s cmdhist shopt -s dotglob shopt -s checkwinsize shopt -s expand_aliases shopt -s histappend # this is overkilled but it works conveniently [[ -d $HOME/.local/share/bash/basher/cellar/packages/junegunn/fzf ]] || basher install junegunn/fzf include junegunn/fzf shell/key-bindings.bash include junegunn/fzf shell/completion.bash export FZF_COMPLETION_OPTS='-x' # Use fd instead of find for fzf_completion _fzf_compgen_path() { fd --hidden --follow --exclude ".git" . "$1" } _fzf_compgen_dir() { fd --type d --hidden --follow --exclude ".git" . "$1" } # Some more completions with fzf _fzf_setup_completion path ag kubectl _fzf_setup_completion dir tree # ^X^R bind "$(bind -s | grep '^"\\C-r"' | sed 's/"/"\\C-x/' | sed 's/"$/\\C-m"/')" # ________ _____ # ___ __ \___________________ _____________ /_ # __ /_/ /_ ___/ __ \_ __ `__ \__ __ \ __/ # _ ____/_ / / /_/ / / / / / /_ /_/ / /_ # /_/ /_/ \____//_/ /_/ /_/_ .___/\__/ # /_/ # # get current branch in git repo parse_git_branch() { BRANCH=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') if [ ! "${BRANCH}" = "" ] then STAT=$(parse_git_dirty) echo "${BRANCH}${STAT}" else echo "" fi } # get current status of git repo parse_git_dirty() { status=$(git status 2>&1 | tee) dirty=$(echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?") untracked=$(echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?") ahead=$(echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?") newfile=$(echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?") renamed=$(echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?") deleted=$(echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?") bits='' if [ "${ahead}" = "0" ]; then bits="*${bits}" fi if [ "${renamed}" = "0" ]; then bits=">${bits}" fi if [ "${newfile}" = "0" ]; then bits="+${bits}" fi if [ "${untracked}" = "0" ]; then bits="?${bits}" fi if [ "${deleted}" = "0" ]; then bits="x${bits}" fi if [ "${dirty}" = "0" ]; then bits="!${bits}" fi if [ ! "${bits}" = "" ]; then echo " ${bits}" else echo "" fi } # Prompt export PS1="\[$(tput bold)\]\[$(tput setaf 1)\]╭─[\[$(tput setaf 3)\]\u\[$(tput setaf 2)\]@\[$(tput setaf 4)\]\h \$(if [[ \$? == 0 ]]; then echo \"\[$(tput setaf 2)\]\342\234\223\"; else echo \"\[$(tput setaf 1)\]\342\234\227\"; fi)\[$(tput setaf 1)\]] \[$(tput setaf 5)\]\w \[$(tput setaf 2)\]\`parse_git_branch\`\n\[$(tput setaf 1)\]╰\[$(tput sgr0)\] " export PS2="\[\e[1;31m\]> " # _________ __________ # __ ____/__________________ /___(_)_____________ _ # _ / __ __ ___/ _ \ _ \ __/_ /__ __ \_ __ `/ # / /_/ / _ / / __/ __/ /_ _ / _ / / / /_/ / # \____/ /_/ \___/\___/\__/ /_/ /_/ /_/_\__, / # /____/ $HOME/.local/bin/bunny