# BASH OPTIONS set -o noclobber -o pipefail shopt -s dotglob extglob globstar histappend nullglob # BASH VARIABLES HISTCONTROL=ignoreboth:erasedups HISTFILE=~/.local/state/bash_history PS1='\[\e[34m\]' # Start color (blue). PS1+='\w ' # Show current working directory followed by a space. PS1+='\[\e[0m\]' # End color. # ENVIRONMENT VARIABLES # Set XDG base directory variables. I don't use these variables in my scripts, # but I set them for software that uses them. export XDG_CACHE_HOME=~/.cache export XDG_CONFIG_HOME=~/.config export XDG_DATA_HOME=~/.local/share export XDG_STATE_HOME=~/.local/state # Set nonstandard XDG base directory variables that some people use. I don't use # these variables in my scripts, but I set them in case any software uses them. export XDG_LOCAL_HOME=~/.local export XDG_BIN_HOME=~/.local/bin export XDG_LIB_HOME=~/.local/lib # Set XDG user directory variables. mapfile -t user_dirs < ~/.config/user-dirs.dirs for line in "${user_dirs[@]}"; do [[ $line =~ ^XDG_ ]] && eval export "$line" done unset line user_dirs # Set these variables to disable accessibility features of GTK, etc. export ACCESSIBILITY_ENABLED=0 export GNOME_ACCESSIBILITY=0 export GTK_A11Y=none export NO_AT_BRIDGE=1 export QT_ACCESSIBILITY=0 export QT_LINUX_ACCESSIBILITY_ALWAYS_ON=0 # Set fzf variables. export FZF_DEFAULT_COMMAND='fd -H --strip-cwd-prefix' export FZF_CTRL_T_COMMAND=$FZF_DEFAULT_COMMAND export FZF_ALT_C_COMMAND="$FZF_DEFAULT_COMMAND -t d" export FZF_DEFAULT_OPTS="--pointer= --prompt=' ' \ --color='bw,hl:-1:regular,fg+:-1:regular,bg+:7,hl+:-1:regular' \ --no-bold --no-height --no-info --no-reverse --no-separator" # Set other environment variables. export EDITOR=emacsclient # Used by `pass`, etc. export GPG_TTY; GPG_TTY=$(tty) # Required by GnuPG. export LC_COLLATE=C.UTF-8 # Improves alphabetical sorting for ls, etc. export LC_TIME=en_US.UTF-8 export LESSHISTFILE=~/.local/state/lesshst export LS_COLORS=di=34:ln=35:ex=32 export NODE_REPL_HISTORY=~/.local/state/node_repl_history export NPM_CONFIG_USERCONFIG=~/.config/npmrc export PASSWORD_STORE_DIR=~/.local/share/password-store export PASSWORD_STORE_GENERATED_LENGTH=30 export PYTHONPYCACHEPREFIX=~/.cache/pycache export TSSERVER_LOG_FILE=~/.local/state/tsserver.log # Is this still needed? export XAUTHORITY=~/.local/state/Xauthority [[ ! $PATH =~ home ]] && PATH=~/main/s/scripts:~/.local/bin:$PATH # FUNCTIONS # Run the given command as a background process. This function is used by my # aliases for GUI apps (see ALIASES below). _background() { ("$@" &> /dev/null &) } # Change the current directory and then list the current directory's contents. # This function is used by my cd alias (see ALIASES below). _cdls() { cd "$@" && ls -Ahl --color --group-directories-first --time-style=long-iso . } # Select a command from selectcmd.dat and insert it into the line buffer. I # execute this function via a Readline key binding (see KEY BINDINGS below). _selectcmd() { local line; line=$(grep '^[^#]' ~/.local/share/selectcmd.dat | fzf) local cmd=${line/* $ } # Remove description. READLINE_LINE=$READLINE_LINE$cmd # Set contents of line buffer. READLINE_POINT=${#READLINE_LINE} # Set insertion point to end of line buffer. } # ALIASES alias c='relocate cp' alias cd=_cdls alias cp='cp -aiv' alias df='df -hTx tmpfs' alias emacs='_background emacs' alias epiphany='_background epiphany' alias evince='_background evince' alias fd='fd --no-ignore-vcs' alias feh='_background feh -T default' alias firefox='_background firefox' alias gimp='_background gimp' alias google-chrome='_background google-chrome' alias gpick='_background gpick' alias grep='grep -Id skip --color=auto' alias less='less -R' alias ls='ls -Ahl --color --group-directories-first --time-style=long-iso' alias ls-size='\ls -AhlrS --color --time-style=long-iso' alias ls-time='\ls -Ahlrt --color --time-style=long-iso' alias lsblk='lsblk -o NAME,PATH,TYPE,FSTYPE,FSSIZE,FSAVAIL,LABEL,MOUNTPOINT,UUID' alias m='relocate mv' alias mkdir='mkdir -pv' alias mv='mv -iv' alias o='xdg-open' alias pc='pass-show -c' alias pe=pass-edit alias pg=pass-generate alias pu=pass-use alias qemu-system-x86_64='_background qemu-system-x86_64' alias r='remove -fr' alias rg='rg --no-ignore-vcs' alias rm='rm -i' alias sudo='sudo env PATH="$PATH" ' # Trailing space ensures that aliases expand. alias tar='tar -v' alias top-u='top -u "$USER"' alias tree='tree -ah --dirsfirst' alias umount='umount -v' alias zathura='_background zathura' # KEY BINDINGS # When binding a key sequence that includes the Alt key, use \e instead of \M- # (such as `bind -x '"\e.":insert-last-argument'`). if [[ -f /usr/share/fzf/shell/key-bindings.bash ]]; then source /usr/share/fzf/shell/key-bindings.bash fi bind -x '"\C-j": _selectcmd'