]> git.zndr.dk Git - dotfiles.git/commitdiff
Change bash prompt
authorJannik ZANDER <jzander@grundfos.com>
Mon, 8 Jan 2018 20:00:19 +0000 (21:00 +0100)
committerJannik ZANDER <jzander@grundfos.com>
Mon, 8 Jan 2018 20:00:19 +0000 (21:00 +0100)
.config/bash/environ
.config/bash/options
.config/bash/prompt.bash
.ssh/config

index cb5e7397e9ba53c7b0df8f2d841239803390ef1c..051574bc8412e26ec6341b3c8c2cb7a80a4bab2b 100644 (file)
@@ -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 !!!
index 3081bae570126b16c0fc8f4e2a56d98c77e3ae47..9d648a2e70d98173a3e0e6e8bb885a7463840c34 100644 (file)
@@ -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`
index ffdbf57f1e7362e006ac4650b04cd6a0047900b4..5a9deed128d771700c1b7f51a898666bbfe9df17 100644 (file)
 #!/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
index 526cafdd16b861a2bee022b22640b6852432836c..db5b8277ac9538c6c4568be77180edb099f8b766 100644 (file)
@@ -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
+