From 3f2d0b1888547435f60b6ac37ada84128aae84cc Mon Sep 17 00:00:00 2001 From: Jonas Forsberg Date: Thu, 11 Nov 2021 16:27:24 +0100 Subject: [PATCH] replaced GBT with new PS1 --- .bashrc | 4 ++-- .gbt.sh | 37 ------------------------------------- .ps1.sh | 38 ++++++++++++++++++++++++++++++++++++++ salt/states/gbt.sls | 18 ------------------ salt/states/top.sls | 1 - 5 files changed, 40 insertions(+), 58 deletions(-) delete mode 100644 .gbt.sh create mode 100644 .ps1.sh delete mode 100644 salt/states/gbt.sls diff --git a/.bashrc b/.bashrc index 09ebe0a..3bd7617 100644 --- a/.bashrc +++ b/.bashrc @@ -23,8 +23,8 @@ fi [[ -x "$(command -v kubectl)" ]] && source <(kubectl completion bash) [[ -x "$(command -v helm)" ]] && source <(helm completion bash) -# Go Bullet Train settings -[[ -f "$HOME/go/bin/gbt" ]] && [[ -f "$HOME/.gbt.sh" ]] && source "$HOME/.gbt.sh" +# PS1 Prompt +[[ -f "$HOME/.ps1.sh" ]] && source "$HOME/.ps1.sh" [[ -f "$HOME/.functions.sh" ]] && source ~/.functions.sh diff --git a/.gbt.sh b/.gbt.sh deleted file mode 100644 index 9c6a78b..0000000 --- a/.gbt.sh +++ /dev/null @@ -1,37 +0,0 @@ -export GBT_SHELL="$0" -export VIRTUAL_ENV_DISABLE_PROMPT=1 -export GBT__SSH_CATCH_PSEUDO_TERMINAL=true -export PS1='$(~/go/bin/gbt $?)' -export GBT_CARS='OS, Custom4, Git, Dir, Custom1, Custom2, Custom3, PyVirtEnv, Status, Sign' -export GBT_CAR_PYVIRTENV_FORMAT='{{ Icon }}' -export GBT_CAR_DIR_BG='dark_gray' -export GBT_CAR_DIR_DEPTH='3' -export GBT_CAR_STATUS_FORMAT=' {{ Code }} ' -export GBT_CAR_SIGN_USER_TEXT='' -export GBT_CAR_CUSTOM1_TEXT_TEXT='MyDot: error' -export GBT_CAR_CUSTOM1_BG='red' -export GBT_CAR_CUSTOM1_DISPLAY_CMD="$HOME/.local/bin/dotfiles_gbt_status.sh check_error" -export GBT_CAR_CUSTOM1_TEXT_TEXT='.error!' -export GBT_CAR_CUSTOM2_BG='green' -export GBT_CAR_CUSTOM2_FG='black' -export GBT_CAR_CUSTOM2_TEXT_TEXT='.c' -export GBT_CAR_CUSTOM2_DISPLAY_CMD="$HOME/.local/bin/dotfiles_gbt_status.sh check_status" -export GBT_CAR_CUSTOM3_TEXT_TEXT='.p' -export GBT_CAR_CUSTOM3_BG='green' -export GBT_CAR_CUSTOM3_FG='black' -export GBT_CAR_CUSTOM3_DISPLAY_CMD="$HOME/.local/bin/dotfiles_gbt_status.sh check_push" -export GBT_CAR_CUSTOM4_TEXT_TEXT='T' -export GBT_CAR_CUSTOM4_BG='yellow' -export GBT_CAR_CUSTOM4_FG='black' -export GBT_CAR_CUSTOM4_DISPLAY_CMD="$HOME/.local/bin/todo_sh_status.sh" -#Kubernetes -export GBT_CAR_KUBECTL_FORMAT=' {{ Context }} ' -#Prompt forward: -export GBT__SSH_IGNORE=(crs ap1 ap2 ap3 ap4) -export GBT__HOME="${HOME}/go/src/github.com/jtyr/gbt" -export GBT__CARS_REMOTE='OS, Hostname, Git, Dir, Status, Sign' -export GBT__THEME_SSH="${HOME}/.gbts_theme.sh" -source ~/go/src/github.com/jtyr/gbt/sources/gbts/cmd/local.sh -alias ssh='gbt_ssh' -alias sudo='gbt_sudo' - diff --git a/.ps1.sh b/.ps1.sh new file mode 100644 index 0000000..c0359b9 --- /dev/null +++ b/.ps1.sh @@ -0,0 +1,38 @@ +#!/bin/bash +function set_bash_prompt () { + local LAST_EXIT_STATUS=$? + local EXIT_STATUS="" + local Color_Off='\033[0m' # Text Reset + + local COLOR_DIVIDER="\033[0;32m" + local COLOR_USERNAME="\[\e[34;1m\]" + local COLOR_USERHOSTAT="\[\e[34;1m\]" + local COLOR_HOSTNAME="\[\e[34;1m\]" + local COLOR_GITBRANCH="\[\e[33;1m\]" + local COLOR_VENV="\033[0;36m" + local PATH_COLOR="\033[0;37m" + + if [[ $LAST_EXIT_STATUS != 0 ]];then + EXIT_STATUS="${COLOR_DIVIDER}<\033[1;37m\033[41m${LAST_EXIT_STATUS}${Color_Off}${COLOR_DIVIDER}>" + fi + + PS1="\n${COLOR_DIVIDER}┌──(${COLOR_USERNAME}\u${COLOR_USERHOSTAT}@${COLOR_HOSTNAME}\h${COLOR_DIVIDER})─[${PATH_COLOR}\w${COLOR_DIVIDER}]${EXIT_STATUS}" + PS1="$PS1${COLOR_GITBRANCH}$(__git_ps1)${COLOR_DIVIDER}" +# # Add git branch portion of the prompt" +# if ! git_loc="$(type -p "$git_command_name")" || [ -z "$git_loc" ]; then +# # Git is installed +# if [ -d .git ] || git rev-parse --is-inside-work-tree > /dev/null 2>&1; then +# # Inside of a git repository +# GIT_BRANCH=$(git symbolic-ref --short HEAD) +# PS1="${PS1}:${COLOR_GITBRANCH}${GIT_BRANCH}${COLOR_DIVIDER}" +# fi +# fi + # Add Python VirtualEnv portion of the prompt, this adds ":venvname" + if ! test -z "$VIRTUAL_ENV" ; then + PS1="${PS1}(${COLOR_VENV}${VIRTUAL_ENV##*/}${COLOR_DIVIDER})" + fi + PS1="${PS1}\n${COLOR_DIVIDER}└─\$${Color_Off} " +} + +# Tell Bash to run the above function for every prompt +export PROMPT_COMMAND=set_bash_prompt diff --git a/salt/states/gbt.sls b/salt/states/gbt.sls deleted file mode 100644 index 516fe01..0000000 --- a/salt/states/gbt.sls +++ /dev/null @@ -1,18 +0,0 @@ -# Install GoBulleTrain, -# Highly configurable prompt builder for Bash, ZSH and PowerShell written in Go. - -Make sure go directory exists: - file.directory: - - name: {{ salt['user.info']( pillar['username']).home }}/go - - user: {{ pillar['username'] }} - - group: users - - mode: "0755" - -{% if not salt['file.directory_exists']('{}/go/src/github.com/jtyr/gbt'.format(salt['user.info']( pillar['username'] ).home )) %} -Go get GBT: - cmd.run: - - name: go get github.com/jtyr/gbt/cmd/gbt - - runas: {{ pillar['username'] }} - - env: - - GOPATH: {{ salt['user.info']( pillar['username']).home }}/go -{% endif %} diff --git a/salt/states/top.sls b/salt/states/top.sls index f4fdfef..2ed836f 100644 --- a/salt/states/top.sls +++ b/salt/states/top.sls @@ -2,7 +2,6 @@ base: '*': - repositories - packages - - gbt - vim - firefox - sudo