dotfiles/_bashrc

162 lines
3.7 KiB
Plaintext
Raw Normal View History

2015-06-13 07:20:32 +00:00
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
2017-05-01 09:18:25 +00:00
##### VARIABLES #####
2015-06-13 07:20:32 +00:00
# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# ... and ignore same sucessive entries.
export HISTCONTROL=ignoreboth
2016-04-27 16:19:18 +00:00
# size
export HISTSIZE=10000
export HISTFILESIZE=100000
2017-05-01 09:18:25 +00:00
# navigateur prefere
export BROWSER=firefox
# editeur par defaut
export EDITOR=vim
export VISUAL=$EDITOR
# pager man conserve affichage à l'écran
export MANPAGER="less -X"
# youtube dl default dl dir FIXME default in youtube
export YDL_TARGET=$HOME
2015-06-13 07:20:32 +00:00
2017-05-01 09:18:25 +00:00
##### COLORS #####
2015-06-13 07:20:32 +00:00
2017-05-01 09:18:25 +00:00
# ls colors
export LSCOLORS="ExGxFxdxCxDxDxhbadExEx"
# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]; then
[ -x /usr/bin/dircolors ] && eval "`dircolors -b`"
2015-06-13 07:20:32 +00:00
fi
2017-05-01 10:51:38 +00:00
RED='\[\033[0;31m\]'
REDB='\[\033[1;31m\]'
2017-05-01 15:51:55 +00:00
GREEN='\[\033[0;32m\]'
GREENB='\[\033[1;32m\]'
YELLOW='\[\033[0;33m\]'
YELLOWB='\[\033[1;33m\]'
2017-05-01 10:51:38 +00:00
BLUE='\033[0;34m\]'
BLUEB='\033[1;34m\]'
2017-05-01 15:51:55 +00:00
PURPLE='\[\033[0;35m\]'
PURPLEB='\[\033[1;35m\]'
CYAN='\[\033[0;36m\]'
CYANB='\[\033[1;36m\]'
2017-05-01 10:51:38 +00:00
WHITE='\[\033[0;37m\]'
WHITEB='\[\033[1;37m\]'
RESET='\[\033[0;00m\]'
2017-05-01 09:18:25 +00:00
##### INCLUDES #####
2015-06-13 07:20:32 +00:00
# Alias definitions.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# host specific
if [ -f ~/.bash_aliases_$(hostname -s) ]; then
. ~/.bash_aliases_$(hostname -s)
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
2017-05-01 09:18:25 +00:00
# FreeBSD
[[ $PS1 && -f /usr/local/share/bash-completion/bash_completion.sh ]] && \
source /usr/local/share/bash-completion/bash_completion.sh
2015-06-13 07:20:32 +00:00
2017-05-01 09:18:25 +00:00
##### MISC #####
2015-06-13 07:20:32 +00:00
2017-05-01 09:18:25 +00:00
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
2015-06-13 07:20:32 +00:00
# conserve l'historique lorsque l'on utilise plusieurs terminaux
shopt -s histappend
2017-05-01 09:18:25 +00:00
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
;;
*)
;;
esac
2015-06-13 07:20:32 +00:00
2017-05-01 09:18:25 +00:00
# Tmux + ssh agent forwarding
if [ -S "$SSH_AUTH_SOCK" ] && [ ! -h "$SSH_AUTH_SOCK" ]; then
ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock
fi
export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock
2015-06-13 07:20:32 +00:00
2017-05-01 09:18:25 +00:00
##### PROMPT #####
2017-05-01 11:04:44 +00:00
prompt_status()
{
2017-05-01 15:51:55 +00:00
if [[ "$exitStatus" == "0" ]]
2017-05-01 11:04:44 +00:00
then
2017-05-01 15:51:55 +00:00
echo -n $GREENB
echo -en '\xE2\x9a\x90'
2017-05-01 11:04:44 +00:00
else
2017-05-01 15:51:55 +00:00
echo -n $REDB
echo -en '\xE2\x9a\x91'
2017-05-01 11:04:44 +00:00
fi
}
prompt_root()
{
if [[ "$(id -u)" == "0" ]]
then
echo -n "${REDB}#"
else
echo -n "${WHITEB}$"
fi
}
2017-05-01 11:09:45 +00:00
prompt_remote()
{
2017-05-01 15:51:55 +00:00
if [[ -n "$SSH_CLIENT" ]]
2017-05-01 11:09:45 +00:00
then
2017-05-01 15:51:55 +00:00
echo -n "${RED}"
2017-05-01 11:09:45 +00:00
else
2017-05-01 15:51:55 +00:00
echo -n "${GREEN}"
2017-05-01 11:09:45 +00:00
fi
}
2017-05-01 15:51:55 +00:00
__ps1pre()
{
export exitStatus=$?
echo -n "${WHITEB}(${WHITE}\u@$(prompt_remote)\h${WHITEB}) ${BLUEB}\w${RESET}"
}
__ps1post()
{
echo -n "\n$(prompt_status) $(prompt_root)${RESET} "
}
2017-05-01 10:51:38 +00:00
__ps1()
{
2017-05-01 15:51:55 +00:00
exitStatus=$?
PS1="$(__ps1pre)$(__ps1post)"
}
__ps1_git()
{
exitStatus=$?
__git_ps1 "$(__ps1pre)" "$(__ps1post)"
2017-05-01 10:51:38 +00:00
}
2017-05-01 15:51:55 +00:00
PROMPT_COMMAND='__ps1'
2015-06-13 07:20:32 +00:00
2017-05-01 09:18:25 +00:00
##### GIT #####
if [ -e /usr/local/share/git-core/contrib/completion/git-completion.bash ]; then
. /usr/local/share/git-core/contrib/completion/git-completion.bash
fi
2016-05-20 17:43:25 +00:00
if [ -e /usr/local/share/git-core/contrib/completion/git-prompt.sh ] || [ -e /usr/lib/git-core/git-sh-prompt ]; then
if [ -e /usr/lib/git-core/git-sh-prompt ]; then
. /usr/lib/git-core/git-sh-prompt
fi
if [ -e /usr/local/share/git-core/contrib/completion/git-prompt.sh ]; then
. /usr/local/share/git-core/contrib/completion/git-prompt.sh
fi
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWSTASHSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWUPSTREAM="auto"
export GIT_PS1_SHOWCOLORHINTS=1
2017-05-01 15:51:55 +00:00
PROMPT_COMMAND='__ps1_git'
fi