From e83e6b215f2e84c69323c87aa21bc5136b42c857 Mon Sep 17 00:00:00 2001 From: Jannik ZANDER Date: Mon, 8 Jan 2018 21:00:19 +0100 Subject: [PATCH] Change bash prompt --- .config/bash/environ | 28 ++++++ .config/bash/options | 6 +- .config/bash/prompt.bash | 197 +++------------------------------------ .ssh/config | 15 ++- 4 files changed, 57 insertions(+), 189 deletions(-) diff --git a/.config/bash/environ b/.config/bash/environ index cb5e739..051574b 100644 --- a/.config/bash/environ +++ b/.config/bash/environ @@ -1,3 +1,31 @@ +# Colors +if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then + export TERM='gnome-256color'; +elif infocmp xterm-256color >/dev/null 2>&1; then + export TERM='xterm-256color'; +fi; + +# Git completion and prompt +source "/usr/share/git/completion/git-completion.bash" +source "/usr/share/git/completion/git-prompt.sh" + +export GIT_PS1_SHOWDIRTYSTATE=true +export GIT_PS1_SHOWCOLORHINTS=true +export GIT_PS1_UNTRACKEDFILES=true + +export PS1="\u@\h:\w (\[\e[32m\]${__git_ps1_branch_name}\[\e[0m\])\$" +export PROMPT_COMMAND="__git_ps1 '\u@\h:\w' '\\$ '" + +# Larger bash history +export HISTFILESIZE=10000; +export HISTSIZE=5000; +export HISTCONTROL=ignoreboth:erasedups +export HISTIGNORE="ll:ls:cd:cd -:pwd:exit:date:* --help"; + +# Whenever displaying the prompt, write the previous line to disk +export PROMPT_COMMAND="$PROMPT_COMMAND; history -a" + + export USERNAME=$LOGNAME export HOSTNAME=`hostname` #echo Welcome $USERNAME. You are on Server: $HOSTNAME !!! diff --git a/.config/bash/options b/.config/bash/options index 3081bae..9d648a2 100644 --- a/.config/bash/options +++ b/.config/bash/options @@ -1,11 +1,11 @@ # Case-insensitive globbing (used in pathname expansion) -shopt -s nocaseglob; +shopt -s nocaseglob # Append to the Bash history file, rather than overwriting it -#shopt -s histappend; +shopt -s histappend # Autocorrect typos in path names when using `cd` -shopt -s cdspell; +shopt -s cdspell # Enable some Bash 4 features when possible: # * `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux` diff --git a/.config/bash/prompt.bash b/.config/bash/prompt.bash index ffdbf57..5a9deed 100644 --- a/.config/bash/prompt.bash +++ b/.config/bash/prompt.bash @@ -1,203 +1,32 @@ #!/bin/bash -# bash_prompt - -# iTerm2 prefs: import Solarized theme (disable bright colors for bold text) -# Color ref: http://vim.wikia.com/wiki/Xterm256_color_names_for_console_Vim -# More tips: http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html - +# Colors if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then export TERM='gnome-256color'; elif infocmp xterm-256color >/dev/null 2>&1; then export TERM='xterm-256color'; fi; -if [ -f "${HOME}/.cache/bash/git-prompt.sh" ]; then - . "${HOME}/.cache/bash/git-prompt.sh" - - # Enabling any of these options will slow down the prompt - export GIT_PS1_SHOWDIRTYSTATE='y' - export GIT_PS1_SHOWSTASHSTATE='y' - export GIT_PS1_SHOWUNTRACKEDFILES='y' - export GIT_PS1_DESCRIBE_STYLE='contains' - export GIT_PS1_SHOWUPSTREAM='auto' -fi - -# Solarized colors -# (https://github.com/altercation/solarized/tree/master/iterm2-colors-solarized#the-values) -set_prompts() -{ -# GREEN="\[$(tput setaf 2)\]" -# RESET="\[$(tput sgr0)\]" -# -## Reset -#Color_Off="\[\033[0m\]" # Text Reset -# -## Regular Colors -#Black="\[\033[0;30m\]" # Black -#Red="\[\033[0;31m\]" # Red -#Green="\[\033[0;32m\]" # Green -#Yellow="\[\033[0;33m\]" # Yellow -#Blue="\[\033[0;34m\]" # Blue -#Purple="\[\033[0;35m\]" # Purple -#Cyan="\[\033[0;36m\]" # Cyan -#White="\[\033[0;37m\]" # White -# -## Bold -#BBlack="\[\033[1;30m\]" # Black -#BRed="\[\033[1;31m\]" # Red -#BGreen="\[\033[1;32m\]" # Green -#BYellow="\[\033[1;33m\]" # Yellow -#BBlue="\[\033[1;34m\]" # Blue -#BPurple="\[\033[1;35m\]" # Purple -#BCyan="\[\033[1;36m\]" # Cyan -#BWhite="\[\033[1;37m\]" # White -# -## Underline -#UBlack="\[\033[4;30m\]" # Black -#URed="\[\033[4;31m\]" # Red -#UGreen="\[\033[4;32m\]" # Green -#UYellow="\[\033[4;33m\]" # Yellow -#UBlue="\[\033[4;34m\]" # Blue -#UPurple="\[\033[4;35m\]" # Purple -#UCyan="\[\033[4;36m\]" # Cyan -#UWhite="\[\033[4;37m\]" # White -# -## Background -#On_Black="\[\033[40m\]" # Black -#On_Red="\[\033[41m\]" # Red -#On_Green="\[\033[42m\]" # Green -#On_Yellow="\[\033[43m\]" # Yellow -#On_Blue="\[\033[44m\]" # Blue -#On_Purple="\[\033[45m\]" # Purple -#On_Cyan="\[\033[46m\]" # Cyan -#On_White="\[\033[47m\]" # White -# -## High Intensty -#IBlack="\[\033[0;90m\]" # Black -#IRed="\[\033[0;91m\]" # Red -#IGreen="\[\033[0;92m\]" # Green -#IYellow="\[\033[0;93m\]" # Yellow -#IBlue="\[\033[0;94m\]" # Blue -#IPurple="\[\033[0;95m\]" # Purple -#ICyan="\[\033[0;96m\]" # Cyan -#IWhite="\[\033[0;97m\]" # White -# -## Bold High Intensty -#BIBlack="\[\033[1;90m\]" # Black -#BIRed="\[\033[1;91m\]" # Red -#BIGreen="\[\033[1;92m\]" # Green -#BIYellow="\[\033[1;93m\]" # Yellow -#BIBlue="\[\033[1;94m\]" # Blue -#BIPurple="\[\033[1;95m\]" # Purple -#BICyan="\[\033[1;96m\]" # Cyan -#BIWhite="\[\033[1;97m\]" # White -# -## High Intensty backgrounds -#On_IBlack="\[\033[0;100m\]" # Black -#On_IRed="\[\033[0;101m\]" # Red -#On_IGreen="\[\033[0;102m\]" # Green -#On_IYellow="\[\033[0;103m\]" # Yellow -#On_IBlue="\[\033[0;104m\]" # Blue -#On_IPurple="\[\033[10;95m\]" # Purple -#On_ICyan="\[\033[0;106m\]" # Cyan -#On_IWhite="\[\033[0;107m\]" # White -# -## Various variables you might want for your PS1 prompt instead -#Time12h="\T" -#Time12a="\@" -#PathShort="\w" -#PathFull="\W" -#NewLine="\n" -#Jobs="\j" -#export PS1="${GREEN}my prompt${RESET}> " - - if [ -x /usr/bin/tput ] && tput setaf 1 >& /dev/null; then - bold=$(tput bold) - reset=$(tput sgr0) - - black=$(tput setaf 0) - blue=$(tput setaf 33) - cyan=$(tput setaf 37) - green=$(tput setaf 64) - orange=$(tput setaf 166) - purple=$(tput setaf 125) - red=$(tput setaf 124) - violet=$(tput setaf 61) - white=$(tput setaf 15) - yellow=$(tput setaf 136) - else - bold="" - reset="\e[0m" - - black="\e[1;30m" - blue="\e[1;34m" - cyan="\e[1;36m" - green="\e[1;32m" - orange="\e[1;33m" - purple="\e[1;35m" - red="\e[1;31m" - violet="\e[1;35m" - white="\e[1;37m" - yellow="\e[1;33m" - fi - - # build the prompt - fg="$white" - - # logged in as root - if [[ "$USER" == "root" ]]; then - userStyle="$bold$red" - else - userStyle="$orange" - fi - - # connected via ssh - if [[ "$SSH_TTY" ]]; then - hostStyle="$bold$red" - else - hostStyle="$yellow" - fi - # Set the terminal title to the current working directory. - PS1="\[\033]0;\w\007\]" +# Git completion and prompt +source "/usr/share/git/completion/git-completion.bash" +source "/usr/share/git/completion/git-prompt.sh" - if [[ "$TERM" == *color ]]; then -# PS1+=$'\r' # carriage return - PS1+="\[$userStyle\]\u" # username - PS1+="\[$reset$fg\] at " - PS1+="\[$hostStyle\]\h" # host - PS1+="\[$reset$fg\] in " - PS1+="\[$green\]\w" # working directory - # PS1+="\$(prompt_git \"$white on $cyan\")" # git repository details - PS1+="\$(__git_ps1 '\[${fg}\] on \[${cyan}\]%s')"; # on branch - PS1+=$'\n' # newline - PS1+="\[$reset$fg\]\$ \[$reset\]" # $ (and reset color) +export GIT_PS1_SHOWDIRTYSTATE=true +export GIT_PS1_SHOWCOLORHINTS=true +export GIT_PS1_UNTRACKEDFILES=true - PS2="\[${yellow}\]-> " - PS2+="\[${reset}\]" # reset color - else # no colors - PS1+=$'\r' # carriage return - PS1+="\u at \h in \w on \$(__git_ps1 %s)" - PS1+=$'\n''\$ ' # newline and $ +export PS1="\u@\h:\w (\[\e[32m\]${__git_ps1_branch_name}\[\e[0m\])\$" +export PROMPT_COMMAND="__git_ps1 '\u@\h:\w' '\\$ '" - PS2="-> " - fi - - export PS1 PS2 -} - - -set_prompts -unset set_prompts - -# When the shell exits, append to the history file instead of overwriting it -shopt -s histappend # Larger bash history export HISTFILESIZE=10000; export HISTSIZE=5000; export HISTCONTROL=ignoreboth:erasedups export HISTIGNORE="ll:ls:cd:cd -:pwd:exit:date:* --help"; + # Whenever displaying the prompt, write the previous line to disk -export PROMPT_COMMAND="history -a" +export PROMPT_COMMAND="$PROMPT_COMMAND; history -a" +# When the shell exits, append to the history file instead of overwriting it +shopt -s histappend diff --git a/.ssh/config b/.ssh/config index 526cafd..db5b827 100644 --- a/.ssh/config +++ b/.ssh/config @@ -1,7 +1,18 @@ -# Global SSH configurations here will be applied to all hosts +# default for all + +# Global SSH configurations here will be applied to all hosts IdentityFile ~/.ssh/github -IdentityFile ~/.ssh/id_rsa IdentityFile ~/.ssh/grundfos IdentityFile ~/.ssh/jira_wdc +# override as per host +Host bitbucket + Hostname bitbucket.org + User jannikz + IdentityFile ~/.ssh/id_rsa + +Host jannik-nas + Hostname 192.168.1.100 + User Jannik + -- 2.43.0