146 lines
3.6 KiB
Bash
146 lines
3.6 KiB
Bash
#
|
|
# ~/.bashrc
|
|
#
|
|
|
|
# ENVIRONMENT VARIABLES
|
|
|
|
# Region preferences
|
|
export LANG=fr_FR.utf8
|
|
export TZ=/usr/share/zoneinfo/Europe/Paris
|
|
|
|
# Favourite commands
|
|
export PAGER=less
|
|
export EDITOR=vim
|
|
export VISUAL=vim
|
|
export BROWSER=qutebrowser
|
|
|
|
# Some programs need those changes
|
|
export PATH="/usr/lib/ccache/bin/:$PATH"
|
|
if [ -d $HOME/.gem/ruby/2.4.0/bin ]; then
|
|
export PATH="$HOME/.gem/ruby/2.4.0/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
|
|
|
|
# ALIASES
|
|
|
|
# Completion for existing commands
|
|
export LS_OPTIONS='--group-directories-first --time-style=+"%d/%m/%Y %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 pacman='pacman --color auto'
|
|
alias dmesg='dmesg --ctime'
|
|
|
|
# Frequent mistakes
|
|
alias systemclt=systemctl
|
|
|
|
# Shortcuts for commonly used commands
|
|
alias ll="ls -l $LS_OPTIONS"
|
|
alias la="ls -la $LS_OPTIONS"
|
|
alias al=sl
|
|
alias x='startx; logout'
|
|
alias s='sudo -s -E'
|
|
alias po='eval $(proxy off)'
|
|
alias nw="sudo systemctl restart NetworkManager"
|
|
alias mc="machines"
|
|
alias tracefiles="strace -f -t -e trace=file"
|
|
alias vpn="sudo systemctl start openvpn-client@$HOSTNAME"
|
|
alias vpno="sudo systemctl stop openvpn-client@$HOSTNAME"
|
|
alias vpns="sudo systemctl status openvpn-client@$HOSTNAME"
|
|
alias vpnr="sudo systemctl restart openvpn-client@$HOSTNAME"
|
|
# Superseding commands with better ones if they are present
|
|
if which vim &> /dev/null; then
|
|
alias vi='vim'
|
|
fi
|
|
if which gopass &> /dev/null; then
|
|
alias pass='gopass'
|
|
fi
|
|
if which wakeonlan &> /dev/null; then
|
|
alias wol='wakeonlan'
|
|
fi
|
|
|
|
# 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=ignoreboth
|
|
|
|
# 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="- "
|
|
|
|
# CUSTOM SCRIPTS
|
|
|
|
export PATH="$HOME/.bin/:$HOME/.scripts/:$PATH"
|
|
[ -f ~/.gscripts/gprofile ] && source ~/.gscripts/gprofile
|
|
|
|
# UTILITIES
|
|
|
|
# Bash completion
|
|
[ -f /etc/bash_completion ] && . /etc/bash_completion
|
|
|
|
# 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)
|
|
|