From 1950387f0b222d9ca51b573a4b287f139e5248c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Sat, 20 Oct 2018 17:04:44 +0200 Subject: Validation initiale --- dotfiles/shell_bash/bashrc | 94 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 dotfiles/shell_bash/bashrc (limited to 'dotfiles/shell_bash/bashrc') diff --git a/dotfiles/shell_bash/bashrc b/dotfiles/shell_bash/bashrc new file mode 100644 index 0000000..8f43283 --- /dev/null +++ b/dotfiles/shell_bash/bashrc @@ -0,0 +1,94 @@ +# +# ~/.bashrc +# + +if [ -n "$HOME/.local/bin" ]; then + PATH="$HOME/.local/bin:$PATH" +fi + +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +export HISTFILE="$XDG_STATE_HOME/bash/history" + +alias vi=vim +alias ls='ls --color=auto -F -T 0' +alias tmux='tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf' + +alias grep='grep --color=auto' +alias fgrep='fgrep --color=auto' +alias egrep='egrep --color=auto' + +alias sudo="sudo " +alias mv="mv -i" +alias cp="cp -i" +alias rm="rm -i" +alias psp="pstree -aUp $USER" +alias dotdrop="dotdrop --cfg $XDG_CONFIG_HOME/dotdrop/config.yaml" + +{%@@ if role.get(profile) == "fretlink" @@%} +##### Some Fretlink aliases +alias getDump='s3cmd -c <(pass show Travail/Fretlink/S3) get ' + +function vpn() { + TMPFILE=$(mktemp /tmp/openvpn.XXXXXX) + pass show Travail/Fretlink/OpenVPN >> $TMPFILE + sudo openvpn $TMPFILE + rm -f $TMPFILE +} + +function dev_prompt() { + if [ -n "$FRETLINK_ENV" ]; then + echo "{$FRETLINK_ENV} " + fi +} +##### /Fretlink +{%@@ endif @@%} + +# Non-printable chars need to be wrapped by \[ ... \] otherwise bash +# will wrongly count the size of the prompt and glitch when going +# through history +function git_prompt_color() { + git diff --quiet 2>/dev/null && git diff --cached --quiet 2>/dev/null + gitstatus=$? + if [ "$gitstatus" -gt 0 ]; then + av=$'\033[01;31m' + else + av=$'\033[01;34m' + fi + echo "$av" +} + +function git_prompt() { + gitinfo=$(git branch 2>/dev/null | grep "^*" | cut -c3-); + git diff --quiet 2>/dev/null && git diff --cached --quiet 2>/dev/null + gitstatus=$? + gitlsfiles=$(git ls-files . 2>/dev/null | wc -l); + if [ "$gitinfo" -a "$gitlsfiles" -gt 0 ]; then + echo -e "($gitinfo) " + fi +} + +function error_code() { + ret=$? + if [[ $ret != 0 ]]; then + echo "$ret " + fi +} + +function running_jobs() { + ret=$(jobs | wc -l) + if [[ $ret != 0 ]]; then + echo "[$ret] " + fi +} + +{%@@ if role.get(profile) == "fretlink" @@%} +PS1='\[\033[01;31m\]$(error_code)\[\033[00;00m\]$(running_jobs)\[\033[01;32m\]$(dev_prompt)\[$(git_prompt_color)\]$(git_prompt)\[\033[00;32m\]\u@\h\[\033[94m\] \w \$\[\033[00m\] ' +{%@@ else @@%} +PS1='\[\033[01;31m\]$(error_code)\[\033[00;00m\]$(running_jobs)\[$(git_prompt_color)\]$(git_prompt)\[\033[00;32m\]\u@\h\[\033[94m\] \w \$\[\033[00m\] ' +{%@@ endif @@%} + +{%@@ if "nodejs" in features.get(profile, []) @@%} +source /usr/share/nvm/init-nvm.sh +{%@@ endif @@%} -- cgit v1.2.3