From 07c9af1e22f872a5f8f80967b2e3f65016da99ab Mon Sep 17 00:00:00 2001 From: Bryan Joshua Pedini Date: Mon, 11 Jan 2021 15:25:38 +0100 Subject: [PATCH] added bashrc ovverrides and relative function to deploy.sh --- bashrc_overrides/_all | 5 +++++ bashrc_overrides/colored_commands | 8 ++++++++ bashrc_overrides/convenience_aliases | 3 +++ bashrc_overrides/git_functions | 23 +++++++++++++++++++++++ bashrc_overrides/histcontrol | 9 +++++++++ bashrc_overrides/ls_aliases | 3 +++ bashrc_overrides/safety_aliases | 3 +++ bashrc_overrides/terminal_colors | 15 +++++++++++++++ bashrc_overrides/terminal_fancyfying | 16 ++++++++++++++++ deploy.sh | 5 +++++ 10 files changed, 90 insertions(+) create mode 100644 bashrc_overrides/_all create mode 100644 bashrc_overrides/colored_commands create mode 100644 bashrc_overrides/convenience_aliases create mode 100644 bashrc_overrides/git_functions create mode 100644 bashrc_overrides/histcontrol create mode 100644 bashrc_overrides/ls_aliases create mode 100644 bashrc_overrides/safety_aliases create mode 100644 bashrc_overrides/terminal_colors create mode 100644 bashrc_overrides/terminal_fancyfying diff --git a/bashrc_overrides/_all b/bashrc_overrides/_all new file mode 100644 index 0000000..b0553f3 --- /dev/null +++ b/bashrc_overrides/_all @@ -0,0 +1,5 @@ +for source in colored_commands convenience_aliases git_functions histcontrol ls_aliases safety_aliases terminal_colors terminal_fancyfying; do + if [ -f $source ]; then + . $source + fi +done diff --git a/bashrc_overrides/colored_commands b/bashrc_overrides/colored_commands new file mode 100644 index 0000000..2849604 --- /dev/null +++ b/bashrc_overrides/colored_commands @@ -0,0 +1,8 @@ +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' + alias diff='diff --color' +fi diff --git a/bashrc_overrides/convenience_aliases b/bashrc_overrides/convenience_aliases new file mode 100644 index 0000000..dd698f5 --- /dev/null +++ b/bashrc_overrides/convenience_aliases @@ -0,0 +1,3 @@ +alias pubkey='cat ~/.ssh/id_rsa.pub' +alias hosts='sudo nano /etc/hosts' +alias historygrep='history | grep' diff --git a/bashrc_overrides/git_functions b/bashrc_overrides/git_functions new file mode 100644 index 0000000..c87102a --- /dev/null +++ b/bashrc_overrides/git_functions @@ -0,0 +1,23 @@ +__git_dirty() { + if [ "$(git status 2> /dev/null | tail -1)" != "nothing to commit, working tree clean" ]; then + echo "*" + fi +} +__git_branch() { +branch=$(git branch 2>/dev/null | grep "*" | sed -e 's/\*\ //') || return + if [ "$branch" == *"detached"* ]; then + branch=$(echo "$branch" | sed -e 's/.*at\ //' | sed -e 's/)//') + fi + echo "$branch" +} +__git_prompt() { + branch=$(__git_branch) + if [ ! -z "$branch" ]; then + echo "$branch$(__git_dirty)" + else + echo "NONE" + fi +} +__git_history() { + echo "$(git log --oneline | cut -d ' ' -f 1)" +} diff --git a/bashrc_overrides/histcontrol b/bashrc_overrides/histcontrol new file mode 100644 index 0000000..f609343 --- /dev/null +++ b/bashrc_overrides/histcontrol @@ -0,0 +1,9 @@ +# append to the history file, don't overwrite it +shopt -s histappend + +# don't put duplicate lines or lines starting with space in the history +HISTCONTROL=ignoreboth + +# create unlimited history in memory/storage (more effective grepping) +HISTSIZE= +HISTFILESIZE= diff --git a/bashrc_overrides/ls_aliases b/bashrc_overrides/ls_aliases new file mode 100644 index 0000000..2338f6b --- /dev/null +++ b/bashrc_overrides/ls_aliases @@ -0,0 +1,3 @@ +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' diff --git a/bashrc_overrides/safety_aliases b/bashrc_overrides/safety_aliases new file mode 100644 index 0000000..aabbc91 --- /dev/null +++ b/bashrc_overrides/safety_aliases @@ -0,0 +1,3 @@ +alias rm='rm -i' +alias mv='mv -i' +alias cp='cp -i' diff --git a/bashrc_overrides/terminal_colors b/bashrc_overrides/terminal_colors new file mode 100644 index 0000000..fad3c0f --- /dev/null +++ b/bashrc_overrides/terminal_colors @@ -0,0 +1,15 @@ +FORMAT_RESET="\[\033[00;37m\]" +FORMAT_BLINK="\[\033[05m\]" +FORMAT_BOLD="\[\033[02m\]" +RED="\[\033[00;31m\]" +LIGHTRED="\[\033[01;31m\]" +GREEN="\[\033[00;32m\]" +LIGHTGREEN="\[\033[01;32m\]" +BROWN="\[\033[00;33m\]" +LIGHTBROWN="\[\033[01;33m\]" +BLUE="\[\033[00;34m\]" +LIGHTBLUE="\[\033[01;34m\]" +PURPLE="\[\033[00;35m\]" +LIGHTPURPLE="\[\033[01;35m\]" +CYAN="\[\033[00;36m\]" +LIGHTCYAN="\[\033[01;36m\]" diff --git a/bashrc_overrides/terminal_fancyfying b/bashrc_overrides/terminal_fancyfying new file mode 100644 index 0000000..74c19d3 --- /dev/null +++ b/bashrc_overrides/terminal_fancyfying @@ -0,0 +1,16 @@ +GIT_FUNCTIONS=true + +# Spaced +#PS1="${LIGHTBLUE}[ ${LIGHTRED}\u ${LIGHTBLUE}@ ${LIGHTBROWN}$(hostname --fqdn) ${LIGHTBLUE}] ${LIGHTPURPLE}( ${GREEN}\w ${LIGHTPURPLE}) " +# Not spaced +#PS1="${LIGHTBLUE}[${LIGHTRED}\u${LIGHTBLUE}@${LIGHTBROWN}$(hostname --fqdn)${LIGHTBLUE}]${LIGHTPURPLE}(${GREEN}\w${LIGHTPURPLE})" +# another version I really like +PS1="${PURPLE}\# ${LIGHTBLUE}{${LIGHTGREEN}\u${BROWN}@${LIGHTGREEN}\$(hostname --fqdn)${LIGHTBLUE}} ${LIGHTPURPLE}[${CYAN}\w${LIGHTPURPLE}] " + +if [ $GIT_FUNCTIONS ]; then + #PS1="$PS1${LIGHTPURPLE}[${LIGHTCYAN}$(__git_prompt)${LIGHTPURPLE}]" + PS1="$PS1${LIGHTBROWN}(${LIGHTCYAN}\$(__git_prompt)${LIGHTBROWN}) " +fi + +#PS1="$PS1${RED}#${FORMAT_RESET}" +PS1="$PS1${RED}${FORMAT_BLINK}\$${FORMAT_RESET}" diff --git a/deploy.sh b/deploy.sh index a78eee0..9e1b2a3 100755 --- a/deploy.sh +++ b/deploy.sh @@ -9,3 +9,8 @@ _cleanup() { chmod +x /tmp/deploy_cleanup.sh echo -e "$(crontab -l)\n# REF:deploy_cleanup:REF\n* * * * *\t/tmp/deploy_cleanup.sh" | crontab - } + +_bash_overrides() { + cp bashrc_overrides ~/.bashrc_overrides + echo -e "if [ -f ~/.bashrc_overrides/_all ]; then\n . ~/.bashrc_overrides\nfi" >> ~/.bashrc +}