2017-02-12 11:41:03 +01:00
|
|
|
#
|
|
|
|
# ~/.bashrc
|
|
|
|
#
|
2015-07-12 18:29:52 +02:00
|
|
|
|
2017-02-12 11:41:03 +01:00
|
|
|
# ENVIRONMENT VARIABLES
|
2016-03-14 13:49:51 +01:00
|
|
|
|
2017-02-12 11:41:03 +01:00
|
|
|
# Favourite commands
|
2016-02-25 20:35:44 +01:00
|
|
|
export PAGER=less
|
2018-10-08 23:52:53 +02:00
|
|
|
export EDITOR=nvim
|
|
|
|
export VISUAL=nvim
|
2017-02-12 11:41:03 +01:00
|
|
|
export BROWSER=qutebrowser
|
2015-07-12 18:29:52 +02:00
|
|
|
|
2017-02-12 11:41:03 +01:00
|
|
|
# Some programs need those changes
|
2017-04-22 18:04:17 +02:00
|
|
|
export PATH="/usr/lib/ccache/bin/:$PATH"
|
2017-09-17 13:36:17 +02:00
|
|
|
if [ -d /data/data/com.termux/ ]; then
|
|
|
|
export PATH="$HOME/.termux/scripts:$HOME/.termux/bin:$PATH"
|
|
|
|
fi
|
2017-02-12 11:41:03 +01:00
|
|
|
#export PATH="$(echo "$PATH" | sed 's|:|\n|g' | sort | uniq | tr '\n' ':' | sed 's|:$||')"
|
2015-07-12 18:29:52 +02:00
|
|
|
export JAVA_FONTS=/usr/share/fonts/TTF
|
2016-04-10 14:05:59 +02:00
|
|
|
export ANDROID_HOME=/opt/android-sdk
|
2016-12-18 15:10:40 +01:00
|
|
|
export GOPATH=$HOME/.go
|
2017-09-01 18:39:06 +02:00
|
|
|
export PATH=$GOPATH/bin:$PATH
|
2017-02-12 11:41:03 +01:00
|
|
|
export XDG_CONFIG_HOME=$HOME/.config
|
2017-06-14 08:06:40 +02:00
|
|
|
export ARDUINO=/usr/share/arduino
|
|
|
|
export ARDUINO_DIR=$ARDUINO
|
|
|
|
export ARDMK_VENDOR=archlinux-arduino
|
2017-09-17 18:42:53 +02:00
|
|
|
export PYTHONSTARTUP=$HOME/.config/pythonstartup.py
|
2015-07-12 18:29:52 +02:00
|
|
|
|
2017-02-12 11:41:03 +01:00
|
|
|
# ALIASES
|
2015-07-12 18:29:52 +02:00
|
|
|
|
2017-02-12 11:41:03 +01:00
|
|
|
# Completion for existing commands
|
2019-01-06 14:05:05 +01:00
|
|
|
export LS_OPTIONS='--group-directories-first --time-style=+"%Y-%m-%d %H:%M:%S" --color=auto --file-type --human-readable'
|
2016-05-12 19:39:38 +02:00
|
|
|
alias ls="ls $LS_OPTIONS"
|
2015-07-12 18:29:52 +02:00
|
|
|
alias grep='grep --color=tty -d skip'
|
2016-05-12 19:39:38 +02:00
|
|
|
alias mkdir='mkdir -v'
|
2019-03-20 22:14:09 +01:00
|
|
|
alias cp="cp -i --reflink=auto"
|
2016-05-12 19:39:38 +02:00
|
|
|
alias mv="mv -iv"
|
|
|
|
alias dd='dd status=progress'
|
|
|
|
alias rm='rm -Iv --one-file-system'
|
|
|
|
alias free='free -m'
|
|
|
|
alias df='df -h'
|
2017-06-14 08:06:40 +02:00
|
|
|
alias dmesg='dmesg --ctime'
|
2018-08-13 12:20:09 +02:00
|
|
|
alias ffmpeg='ffmpeg -hide_banner'
|
|
|
|
alias ffprobe='ffprobe -hide_banner'
|
|
|
|
alias ffplay='ffplay -hide_banner'
|
2017-06-14 08:06:40 +02:00
|
|
|
|
|
|
|
# Frequent mistakes
|
2018-01-22 08:29:43 +01:00
|
|
|
alias sl=ls
|
|
|
|
alias al=la
|
|
|
|
alias mdkir=mkdir
|
2017-06-14 08:06:40 +02:00
|
|
|
alias systemclt=systemctl
|
2018-10-18 21:14:11 +02:00
|
|
|
alias please=sudo
|
2017-02-12 11:41:03 +01:00
|
|
|
|
|
|
|
# Shortcuts for commonly used commands
|
|
|
|
alias ll="ls -l $LS_OPTIONS"
|
|
|
|
alias la="ls -la $LS_OPTIONS"
|
2016-12-08 21:43:45 +01:00
|
|
|
alias x='startx; logout'
|
2019-01-06 14:05:05 +01:00
|
|
|
alias nx='nvidia-xrun; logout'
|
2016-12-11 23:13:54 +01:00
|
|
|
alias s='sudo -s -E'
|
2017-08-22 07:57:52 +02:00
|
|
|
alias tracefiles="strace -f -t -e trace=file"
|
2018-05-21 10:57:19 +02:00
|
|
|
alias n='urxvtc &'
|
2018-01-08 12:26:49 +01:00
|
|
|
|
2017-02-12 11:41:03 +01:00
|
|
|
# Superseding commands with better ones if they are present
|
2018-08-13 12:20:09 +02:00
|
|
|
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"
|
2018-04-10 15:38:18 +02:00
|
|
|
}
|
2018-08-13 12:20:09 +02:00
|
|
|
|
|
|
|
function _install_rank() { # executables...
|
|
|
|
for ex in "$@"
|
|
|
|
do
|
|
|
|
list=$@
|
|
|
|
alias "$ex"="_do_rank $list --"
|
|
|
|
done
|
2018-04-10 15:38:18 +02:00
|
|
|
}
|
2015-09-24 18:08:29 +02:00
|
|
|
|
2018-08-13 12:20:09 +02:00
|
|
|
_install_rank nvim vim vi
|
|
|
|
_install_rank gopass pass
|
|
|
|
_install_rank wakeonlan wol
|
|
|
|
_install_rank neomutt mutt
|
2015-09-24 18:08:29 +02:00
|
|
|
|
2017-02-12 11:41:03 +01:00
|
|
|
# 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
|
|
|
|
|
2017-06-14 08:06:40 +02:00
|
|
|
export HISTSIZE=100000
|
2017-02-12 11:41:03 +01:00
|
|
|
export HISTFILESIZE=${HISTSIZE}
|
2018-04-10 15:38:18 +02:00
|
|
|
export HISTCONTROL=ignorespace:erasedups
|
2018-06-24 18:27:20 +02:00
|
|
|
export HISTTIMEFORMAT="%y-%m-%d %H:%M:%S "
|
2017-02-12 11:41:03 +01:00
|
|
|
|
|
|
|
# PROMPT CUSTOMIZATION
|
|
|
|
|
|
|
|
if [[ $USER == 'root' ]]; then
|
|
|
|
col=31;
|
|
|
|
elif [[ $USER == 'geoffrey' || $USER == 'gbontoux' || $USER == 'gpreud' ]]; then
|
|
|
|
col=32;
|
|
|
|
else
|
|
|
|
col=33;
|
2017-01-16 20:17:09 +01:00
|
|
|
fi
|
2017-02-12 15:14:51 +01:00
|
|
|
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="- "
|
2018-04-15 16:29:27 +02:00
|
|
|
export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}:${PWD}\007"'
|
2017-02-12 15:14:51 +01:00
|
|
|
|
|
|
|
# CUSTOM SCRIPTS
|
|
|
|
|
2018-08-19 11:29:59 +02:00
|
|
|
export PATH="$HOME/.local/bin/:$HOME/.scripts/:$PATH"
|
2017-02-12 15:14:51 +01:00
|
|
|
[ -f ~/.gscripts/gprofile ] && source ~/.gscripts/gprofile
|
2017-01-16 20:17:09 +01:00
|
|
|
|
2017-02-12 11:41:03 +01:00
|
|
|
# UTILITIES
|
2015-07-12 18:29:52 +02:00
|
|
|
|
2018-07-30 10:55:06 +02:00
|
|
|
# Theme
|
2018-08-19 11:29:59 +02:00
|
|
|
[ -f ~/.local/bin/colorSchemeApply ] && source ~/.local/bin/colorSchemeApply
|
|
|
|
[ -f ~/.local/bin/colorSchemeApplyFzf ] && source ~/.local/bin/colorSchemeApplyFzf
|
2018-07-30 10:55:06 +02:00
|
|
|
|
2017-02-12 11:41:03 +01:00
|
|
|
# Bash completion
|
2018-07-30 10:55:06 +02:00
|
|
|
[ -f /etc/bash_completion ] && source /etc/bash_completion
|
2015-07-12 18:29:52 +02:00
|
|
|
|
2018-06-24 18:27:20 +02:00
|
|
|
# Fuzzy matching all the way
|
2018-07-30 10:55:06 +02:00
|
|
|
export FZF_DEFAULT_OPTS="${FZF_DEFAULT_OPTS} --height 100% --layout=default"
|
2018-06-24 18:27:20 +02:00
|
|
|
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
|
2015-07-12 18:29:52 +02:00
|
|
|
|
2017-02-12 11:41:03 +01:00
|
|
|
# Bad day mood-saver
|
2017-06-21 20:05:05 +02:00
|
|
|
function fuck {
|
2017-06-14 09:26:25 +02:00
|
|
|
if which thefuck &> /dev/null
|
|
|
|
then
|
|
|
|
eval $(thefuck --alias)
|
2017-06-27 09:19:26 +02:00
|
|
|
fuck $@
|
2017-06-14 09:26:25 +02:00
|
|
|
else
|
|
|
|
echo "thefuck is not installed on this system."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
alias FUCK='fuck'
|
|
|
|
|
|
|
|
# Node Version Manager
|
2017-06-21 20:05:05 +02:00
|
|
|
function nvm {
|
2017-06-27 09:19:26 +02:00
|
|
|
export NVM_DIR="$HOME/.nvm"
|
2017-06-14 09:26:25 +02:00
|
|
|
if [ -s "$NVM_DIR/nvm.sh" ]
|
|
|
|
then
|
|
|
|
. "$NVM_DIR/nvm.sh"
|
|
|
|
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
|
2017-06-27 09:19:26 +02:00
|
|
|
nvm $@
|
2017-06-14 09:26:25 +02:00
|
|
|
else
|
|
|
|
echo "NVM is not installed on this system."
|
|
|
|
fi
|
|
|
|
}
|
2015-07-12 18:29:52 +02:00
|
|
|
|
2017-02-12 15:14:51 +01:00
|
|
|
# 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)
|
2016-04-10 14:05:59 +02:00
|
|
|
|