# # ~/.bashrc # # ENVIRONMENT VARIABLES # Favourite commands export PAGER=less export EDITOR=nvim export VISUAL=nvim export BROWSER=qutebrowser # Some programs need those changes export PATH="/usr/lib/ccache/bin/:$PATH" if [ -d /data/data/com.termux/ ]; then export PATH="$HOME/.termux/scripts:$HOME/.termux/bin:$PATH" fi #export PATH="$(echo "$PATH" | sed 's|:|\n|g' | sort | uniq | tr '\n' ':' | sed 's|:$||')" export JAVA_FONTS=/usr/share/fonts/TTF export ANDROID_HOME=/opt/android-sdk export GOPATH=$HOME/.go export PATH=$GOPATH/bin:$PATH export XDG_CONFIG_HOME=$HOME/.config export ARDUINO=/usr/share/arduino export ARDUINO_DIR=$ARDUINO export ARDMK_VENDOR=archlinux-arduino export PYTHONSTARTUP=$HOME/.config/pythonstartup.py # ALIASES # Completion for existing commands export LS_OPTIONS='--group-directories-first --time-style=+"%Y-%m-%d %H:%M:%S" --color=auto --file-type --human-readable' alias ls="ls $LS_OPTIONS" alias grep='grep --color=tty -d skip' alias mkdir='mkdir -v' alias cp="cp -i" alias mv="mv -iv" alias dd='dd status=progress' alias rm='rm -Iv --one-file-system' alias free='free -m' alias df='df -h' alias dmesg='dmesg --ctime' alias ffmpeg='ffmpeg -hide_banner' alias ffprobe='ffprobe -hide_banner' alias ffplay='ffplay -hide_banner' # Frequent mistakes alias sl=ls alias al=la alias mdkir=mkdir alias systemclt=systemctl alias please=sudo # Shortcuts for commonly used commands alias ll="ls -l $LS_OPTIONS" alias la="ls -la $LS_OPTIONS" alias x='startx; logout' alias nx='nvidia-xrun; logout' alias s='sudo -s -E' alias tracefiles="strace -f -t -e trace=file" alias n='urxvtc &' # Superseding commands with better ones if they are present function _do_rank() { # executables... -- arguments... for ex in "$@" do [ "$ex" == "--" ] && break if which "$ex" &> /dev/null then for al in "$@" do shift [ "$al" == "--" ] && break alias "$al"="$ex" done "$ex" "$@" return $? fi done for ex in "$@" do [ "$al" == "--" ] && break if -z "$list" then list=$ex else list=$list, $ex fi done echo "Not installed: $list" } function _install_rank() { # executables... for ex in "$@" do list=$@ alias "$ex"="_do_rank $list --" done } _install_rank nvim vim vi _install_rank gopass pass _install_rank wakeonlan wol _install_rank neomutt mutt # SHELL CUSTOMIZATION complete -cf sudo shopt -s cdspell shopt -s checkwinsize shopt -s cmdhist shopt -s dotglob shopt -s expand_aliases shopt -s extglob shopt -s histappend shopt -s hostcomplete export HISTSIZE=100000 export HISTFILESIZE=${HISTSIZE} export HISTCONTROL=ignorespace:erasedups export HISTTIMEFORMAT="%y-%m-%d %H:%M:%S " # PROMPT CUSTOMIZATION if [[ $USER == 'root' ]]; then col=31; elif [[ $USER == 'geoffrey' || $USER == 'gbontoux' || $USER == 'gpreud' ]]; then col=32; else col=33; fi export PS1="\[\e]2;\u@\h \w\a\]\[\e[0;37m\][\[\e[0;${col}m\]\u\[\e[0;37m\]@\[\e[0;34m\]\h \[\e[0;36m\]\W\[\e[0;37m\]]\$\[\e[0m\] " export PS2="> " export PS3="+ " export PS4="- " export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}:${PWD}\007"' # CUSTOM SCRIPTS export PATH="$HOME/.local/bin/:$HOME/.scripts/:$PATH" [ -f ~/.gscripts/gprofile ] && source ~/.gscripts/gprofile # UTILITIES # Theme [ -f ~/.local/bin/colorSchemeApply ] && source ~/.local/bin/colorSchemeApply [ -f ~/.local/bin/colorSchemeApplyFzf ] && source ~/.local/bin/colorSchemeApplyFzf # Bash completion [ -f /etc/bash_completion ] && source /etc/bash_completion # Fuzzy matching all the way export FZF_DEFAULT_OPTS="${FZF_DEFAULT_OPTS} --height 100% --layout=default" export FZF_CTRL_T_OPTS="--preview '[[ -d {} ]] && ls -l --color=always {} || [[ \$(file --mime {}) =~ binary ]] && echo {} is a binary file || (highlight -O ansi -l {} || coderay {} || rougify {} || cat {}) 2> /dev/null | head -500'" export FZF_COMPLETION_OPTS="${FZF_CTRL_T_OPTS}" [ -f /usr/share/fzf/completion.bash ] && source /usr/share/fzf/completion.bash [ -f /usr/share/fzf/key-bindings.bash ] && source /usr/share/fzf/key-bindings.bash # Bad day mood-saver function fuck { if which thefuck &> /dev/null then eval $(thefuck --alias) fuck $@ else echo "thefuck is not installed on this system." fi } alias FUCK='fuck' # Node Version Manager function nvm { export NVM_DIR="$HOME/.nvm" if [ -s "$NVM_DIR/nvm.sh" ] then . "$NVM_DIR/nvm.sh" [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" nvm $@ else echo "NVM is not installed on this system." fi } # Command not found handlers [ -r /usr/share/doc/pkgfile/command-not-found.bash ] && . /usr/share/doc/pkgfile/command-not-found.bash # Arch [ -r /etc/profile.d/cnf.sh ] && . /etc/profile.d/cnf.sh # Arch (alternative, for Manjaro mostly)