From 0609db42652a4fa0f122e332bab44538c953e458 Mon Sep 17 00:00:00 2001 From: "@@@No user configured@@@" <@@@No user configured@@@> Date: Tue, 17 Nov 2015 12:07:59 +0100 Subject: [PATCH] Add bashrc module. --- files/bashrc.d/01-private-bin.sh | 10 ++++ files/bashrc.d/02-debian-variables.sh | 6 +++ files/bashrc.d/05-android.sh | 10 ++++ files/bashrc.d/05-go.sh | 12 +++++ files/bashrc.d/05-opam.sh | 11 ++++ files/bashrc.d/05-rbenv.sh | 10 ++++ files/bashrc.d/06-gnusidecloud.sh | 10 ++++ files/bashrc.d/06-ruboto.sh | 8 +++ files/bashrc.d/09-pager.sh | 10 ++++ files/bashrc.d/11-gpg-agent.sh | 12 +++++ files/bashrc.d/11-grep-options.sh | 5 ++ files/bashrc.d/98-fake-resolv-host.sh | 3 ++ files/bashrc.d/99-aliases.sh | 14 +++++ files/bashrc.d/99-completion-rmplayer.sh | 12 +++++ files/bashrc.d/99-misc.sh | 57 +++++++++++++++++++++ files/bashrc.d/99-prompt.sh | 56 ++++++++++++++++++++ files/bashrc.d/99-system-bash-completion.sh | 8 +++ tasks/main.yml | 15 ++++++ templates/bashrc.jinja2 | 12 +++++ 19 files changed, 281 insertions(+) create mode 100644 files/bashrc.d/01-private-bin.sh create mode 100644 files/bashrc.d/02-debian-variables.sh create mode 100644 files/bashrc.d/05-android.sh create mode 100644 files/bashrc.d/05-go.sh create mode 100644 files/bashrc.d/05-opam.sh create mode 100644 files/bashrc.d/05-rbenv.sh create mode 100644 files/bashrc.d/06-gnusidecloud.sh create mode 100644 files/bashrc.d/06-ruboto.sh create mode 100644 files/bashrc.d/09-pager.sh create mode 100644 files/bashrc.d/11-gpg-agent.sh create mode 100644 files/bashrc.d/11-grep-options.sh create mode 100644 files/bashrc.d/98-fake-resolv-host.sh create mode 100644 files/bashrc.d/99-aliases.sh create mode 100644 files/bashrc.d/99-completion-rmplayer.sh create mode 100644 files/bashrc.d/99-misc.sh create mode 100644 files/bashrc.d/99-prompt.sh create mode 100644 files/bashrc.d/99-system-bash-completion.sh create mode 100644 templates/bashrc.jinja2 diff --git a/files/bashrc.d/01-private-bin.sh b/files/bashrc.d/01-private-bin.sh new file mode 100644 index 0000000..5b36358 --- /dev/null +++ b/files/bashrc.d/01-private-bin.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +### +# set PATH so it includes user's private bin if it exists +# + +if [ -d "$HOME/bin" ] ; then + export PATH="$HOME/bin:$PATH" +fi + diff --git a/files/bashrc.d/02-debian-variables.sh b/files/bashrc.d/02-debian-variables.sh new file mode 100644 index 0000000..ca88e00 --- /dev/null +++ b/files/bashrc.d/02-debian-variables.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +export DEBEMAIL="glenux@glenux.net" +export DEBFULLNAME="Glenn Y. Rolland" +export buildArea=$HOME/debian/build-area + diff --git a/files/bashrc.d/05-android.sh b/files/bashrc.d/05-android.sh new file mode 100644 index 0000000..a5b493f --- /dev/null +++ b/files/bashrc.d/05-android.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +### +# Set up Android environment +# +ANDROIDDIR=$HOME/.adt-bundle +if [[ -e "$ANDROIDDIR" ]]; then + export PATH=$ANDROIDDIR/sdk/platform-tools:$ANDROIDDIR/sdk/tools:$PATH +fi + diff --git a/files/bashrc.d/05-go.sh b/files/bashrc.d/05-go.sh new file mode 100644 index 0000000..ac3cb0f --- /dev/null +++ b/files/bashrc.d/05-go.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +## +# Set up Go environment +# + +if hash go > /dev/null 2>&1; then + if [ -d "$HOME/bin" ]; then + export GOPATH="$HOME/src/Go" + export PATH="$GOPATH/bin:$PATH" + fi +fi diff --git a/files/bashrc.d/05-opam.sh b/files/bashrc.d/05-opam.sh new file mode 100644 index 0000000..a2cb195 --- /dev/null +++ b/files/bashrc.d/05-opam.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +## +# Set up OCaml environment +# +if hash opam > /dev/null 2>&1 ; then + eval $(opam config env) +fi + +# OPAM configuration +#. /home/warbrain/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true diff --git a/files/bashrc.d/05-rbenv.sh b/files/bashrc.d/05-rbenv.sh new file mode 100644 index 0000000..294c4dc --- /dev/null +++ b/files/bashrc.d/05-rbenv.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +### +# Set up Ruby environment +# +#export PATH=/var/lib/gems/1.8/bin:$PATH +if [[ -s "$HOME/.rbenv/bin/rbenv" ]]; then + export PATH="$HOME/.rbenv/bin:$PATH" + eval "$(rbenv init -)" +fi diff --git a/files/bashrc.d/06-gnusidecloud.sh b/files/bashrc.d/06-gnusidecloud.sh new file mode 100644 index 0000000..9ed0cd8 --- /dev/null +++ b/files/bashrc.d/06-gnusidecloud.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +### +# Set up GNUSIDE CLOUD environment +# +GNUSIDE_CLOUD_PATH="$HOME/Documents/_GnusideCloud" + +if [[ -s "$GNUSIDE_CLOUD_PATH/bin" ]]; then + export PATH="$GNUSIDE_CLOUD_PATH/bin:$PATH" +fi diff --git a/files/bashrc.d/06-ruboto.sh b/files/bashrc.d/06-ruboto.sh new file mode 100644 index 0000000..219ea13 --- /dev/null +++ b/files/bashrc.d/06-ruboto.sh @@ -0,0 +1,8 @@ +export PATH +export ANDROID_HOME + +if [ -d "$HOME/android-sdk-linux" ]; then + PATH="$HOME/android-sdk-linux/build-tools/19.1.0:$PATH" + PATH="$HOME/android-sdk-linux/tools:$PATH" + ANDROID_HOME="$HOME/android-sdk-linux/" +fi diff --git a/files/bashrc.d/09-pager.sh b/files/bashrc.d/09-pager.sh new file mode 100644 index 0000000..a15a018 --- /dev/null +++ b/files/bashrc.d/09-pager.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# Pager detection +for pager in most less more ; do + if hash $pager 2> /dev/null ; then + export PAGER=$pager + break + fi +done + diff --git a/files/bashrc.d/11-gpg-agent.sh b/files/bashrc.d/11-gpg-agent.sh new file mode 100644 index 0000000..2307069 --- /dev/null +++ b/files/bashrc.d/11-gpg-agent.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +### +# GnuPG +# +if [ -f "${HOME}/.gpg-agent-info" ]; then + . "${HOME}/.gpg-agent-info" + export GPG_AGENT_INFO + export SSH_AUTH_SOCK +fi + + diff --git a/files/bashrc.d/11-grep-options.sh b/files/bashrc.d/11-grep-options.sh new file mode 100644 index 0000000..ce5b781 --- /dev/null +++ b/files/bashrc.d/11-grep-options.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +#export GREP_OPTIONS="--color" +#GREP_COLORS="ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36" +#export GREP_COLORS diff --git a/files/bashrc.d/98-fake-resolv-host.sh b/files/bashrc.d/98-fake-resolv-host.sh new file mode 100644 index 0000000..2fbca1f --- /dev/null +++ b/files/bashrc.d/98-fake-resolv-host.sh @@ -0,0 +1,3 @@ + +#echo "[ERROR] Fake resolv & host is not set up" >&2 + diff --git a/files/bashrc.d/99-aliases.sh b/files/bashrc.d/99-aliases.sh new file mode 100644 index 0000000..8935d1f --- /dev/null +++ b/files/bashrc.d/99-aliases.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +## +# ALIAS DEFINITIONS. +# + +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + diff --git a/files/bashrc.d/99-completion-rmplayer.sh b/files/bashrc.d/99-completion-rmplayer.sh new file mode 100644 index 0000000..9df351a --- /dev/null +++ b/files/bashrc.d/99-completion-rmplayer.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# completion programmable sur les URLs qui vont bien +complete -W " 'mms://vip7.yacast.fr/encoderouifm' +'mms://vipbu.yacast.fr/encoderouifm' +'mms://vip2.yacast.fr/encoderfun1' +'mms://vipbu.yacast.fr/encoderfun' +'mms://vip1.yacast.fr/encodernrj' +'mms://vipbu.yacast.fr/encodernrj' +'mms://vip1.yacast.fr/encodernostalgie' +" rmplayer + diff --git a/files/bashrc.d/99-misc.sh b/files/bashrc.d/99-misc.sh new file mode 100644 index 0000000..052682d --- /dev/null +++ b/files/bashrc.d/99-misc.sh @@ -0,0 +1,57 @@ +#source /etc/bash_completion + +export EDITOR=vim + +# disable deprecated variable +export GREP_OPTIONS= + +# load sub-bashrc + +## 01-10 environment changes (XX-environment-...) +## 11-20 applications specific environment changes (XX-application-...) +## 81-99 shell customisation (colors, prompt, etc.) +## 91-99 aliases and completion + +export SHELL_ISLOGIN=${SHELL_ISLOGIN:-0} +#echo $SHELL_ISLOGIN + +# don't put duplicate lines in the history. See bash(1) for more options +export HISTCONTROL=ignoredups + +### +# DISPLAY & COLORS +# + +export LS_COLORS="$LS_COLORS*.flac=01;35:" + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +#??? shopt -s checkwinsize + + +# This line was appended by KDE +# Make sure our customised gtkrc file is loaded. +# export GTK2_RC_FILES=$HOME/.gtkrc-2.0 + + +## +# APPLICATION-SPECIFIC SETUP +# + +# This line was appended by KDE +# Make sure our customised gtkrc file is loaded. +export GTK2_RC_FILES=$HOME/.gtkrc-2.0 + +# Help darcs on network mounts +export DARCS_SLOPPY_LOCKS=1 + +# Disable ansible cowsay +export ANSIBLE_NOCOWS=1 + +function godir() { + dir=$(gx-search-baloo "$@") + cd "$dir" +} + + + diff --git a/files/bashrc.d/99-prompt.sh b/files/bashrc.d/99-prompt.sh new file mode 100644 index 0000000..46f5dae --- /dev/null +++ b/files/bashrc.d/99-prompt.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +## +# PROMPT DEFINITIONS. +# + +ps1_show() { + local format=$1 + local fun=$2 + local str=$($fun) + + if [ ! -z "$str" ]; then + printf "$format\n" "$str" + fi +} + +ps1_vcs_branch() { + local vcs="" + local vcs_branch="" + local vcs_root="" + local vcs_root_path="" + local vcs_root_url="" + local vcs_branch_url="" + + if hash git && git rev-parse > /dev/null 2>&1; then + vcs="git" + vcs_branch=$(git branch |sed -n "s/\* \(.*\)/\1/p") + elif hash hg && hg -q status > /dev/null 2>&1; then + vcs="hg" + vcs_branch=$(hg branch) + elif hash svn && svn info > /dev/null 2>&1; then + vcs="svn" + vcs_root_path=$(LANG=C LC_ALL=C svn info |sed -n "s/^Working Copy Root Path: //p") + vcs_root_url=$(cd "$vcs_root" ; LANG=C LC_ALL=C svn info |sed -n "s/^Repository Root: //p") + vcs_branch_url=$(cd "$vcs_root" ; LANG=C LC_ALL=C svn info |sed -n "s/^URL: //p") + vcs_branch=$(echo "$vcs_branch_url" |sed "s#^$vcs_root_url/##") + fi + + if [ -z "$vcs" ]; then + echo "" + else + echo "$vcs:$vcs_branch" + fi +} + +#export PS1=" \t [#\#]\n[\u@\h \w]\\$ " +#PS1='\[\033[1;32m\][\t|\d]\[\033[1;33m\][\u@\h] \[\033[0;36m\]\w\$\[\033[0m\]\n ' +PS1="$ps1_context ." +PS1=$PS1": \[\e[1;33m\]\w\[\e[0m\] :" +PS1=$PS1"\`ps1_show ': \[\e[1;34m\]%s\[\e[0m\] :' ps1_vcs_branch\`" # vcs branch +PS1=$PS1": \[\e[0;32m\]\t\[\e[0m\] :" +#PS1=$PS1": \[\e[1;34m\]#\#\[\e[0m\] :" #command count +PS1=$PS1": \[\e[0;31m\]\u@\h " #username +PS1=$PS1"("`uname -m`")\[\e[0m\] :" # architecture +PS1=$PS1":.\n\$ " +export PS1 diff --git a/files/bashrc.d/99-system-bash-completion.sh b/files/bashrc.d/99-system-bash-completion.sh new file mode 100644 index 0000000..8d5c67e --- /dev/null +++ b/files/bashrc.d/99-system-bash-completion.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +## +# BASH COMPLETION +# +if [ -f /etc/bash_completion ] && ! shopt -oq posix; then + . /etc/bash_completion +fi diff --git a/tasks/main.yml b/tasks/main.yml index 1a5e913..2da2f58 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,2 +1,17 @@ --- # tasks file for roles/glenux.bash +- name: Install bashrc + + + fileglob: + - bashrc.d/*.sh + +- name: Install bashrc.d files + copy: + "src={{item}}" + "dest=~/.bashrc.d/{{item|basename}}" + with_nested: + - bash_users + - bash_files + become: true + become_user: "{{item}}" diff --git a/templates/bashrc.jinja2 b/templates/bashrc.jinja2 new file mode 100644 index 0000000..c604b28 --- /dev/null +++ b/templates/bashrc.jinja2 @@ -0,0 +1,12 @@ +## +## BASH RC - every new shell +##  + +if [ -d "$HOME/.bashrc.d" ]; then + for script in $(find "$HOME/.bashrc.d/" -name '*.sh' |sort -n) ; do + # echo "Loading `basename \"$script\"`..." # >&2 + . $script + done +fi + +