From 62757b0f3f327b26f7386daeb826d1d4cebd5057 Mon Sep 17 00:00:00 2001 From: Zhao Li Date: Mon, 8 Jul 2019 10:52:44 -1000 Subject: [PATCH 01/32] allow the count information to be turned on or off --- themes/base.theme.bash | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 430fb60d..817c983d 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -33,6 +33,7 @@ SCM_GIT_IGNORE_UNTRACKED=${SCM_GIT_IGNORE_UNTRACKED:=false} SCM_GIT_SHOW_CURRENT_USER=${SCM_GIT_SHOW_CURRENT_USER:=false} SCM_GIT_SHOW_MINIMAL_INFO=${SCM_GIT_SHOW_MINIMAL_INFO:=false} SCM_GIT_SHOW_STASH_INFO=${SCM_GIT_SHOW_STASH_INFO:=true} +SCM_GIT_SHOW_COMMIT_COUNT=${SCM_GIT_SHOW_COMMIT_COUNT:=true} SCM_GIT='git' SCM_GIT_CHAR='±' @@ -181,8 +182,14 @@ function git_prompt_vars { fi IFS=$'\t' read -r commits_behind commits_ahead <<< "$(_git-upstream-behind-ahead)" - [[ "${commits_ahead}" -gt 0 ]] && SCM_BRANCH+="${SCM_GIT_AHEAD_BEHIND_PREFIX_CHAR}${SCM_GIT_AHEAD_CHAR}${commits_ahead}" - [[ "${commits_behind}" -gt 0 ]] && SCM_BRANCH+="${SCM_GIT_AHEAD_BEHIND_PREFIX_CHAR}${SCM_GIT_BEHIND_CHAR}${commits_behind}" + if [[ "${commits_ahead}" -gt 0 ]]; then + SCM_BRANCH+="${SCM_GIT_AHEAD_BEHIND_PREFIX_CHAR}${SCM_GIT_AHEAD_CHAR}" + [[ "${SCM_GIT_SHOW_COMMIT_COUNT}" = "true" ]] && SCM_BRANCH+="${commits_ahead}" + fi + if [[ "${commits_behind}" -gt 0 ]]; then + SCM_BRANCH+="${SCM_GIT_AHEAD_BEHIND_PREFIX_CHAR}${SCM_GIT_BEHIND_CHAR}" + [[ "${SCM_GIT_SHOW_COMMIT_COUNT}" = "true" ]] && SCM_BRANCH+="${commits_behind}" + fi if [[ "${SCM_GIT_SHOW_STASH_INFO}" = "true" ]]; then local stash_count From 83be21ebb35bfb11d47be8b43e5bf3e3cd332b44 Mon Sep 17 00:00:00 2001 From: Zhao Li Date: Mon, 8 Jul 2019 13:10:19 -1000 Subject: [PATCH 02/32] update tests to set flag appropriately --- test/themes/base.theme.git.bats | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/themes/base.theme.git.bats b/test/themes/base.theme.git.bats index 4547a6e3..bae8e021 100644 --- a/test/themes/base.theme.git.bats +++ b/test/themes/base.theme.git.bats @@ -72,6 +72,8 @@ setup_repo_with_upstream() { git clone "$remote" clone cd clone + SCM_GIT_SHOW_COMMIT_COUNT=true + git_prompt_vars assert_equal "$SCM_BRANCH" "${pre}" @@ -146,6 +148,7 @@ setup_repo_with_upstream() { pushd "${repo}" SCM_GIT_SHOW_REMOTE_INFO=true + SCM_GIT_SHOW_COMMIT_COUNT=true git_prompt_vars assert_equal "$SCM_BRANCH" "${pre}my-remote${post}" @@ -166,6 +169,7 @@ setup_repo_with_upstream() { pushd "${repo}" SCM_GIT_SHOW_REMOTE_INFO=auto + SCM_GIT_SHOW_COMMIT_COUNT=true git_prompt_vars assert_equal "$SCM_BRANCH" "${pre}${post}" @@ -202,6 +206,7 @@ setup_repo_with_upstream() { git remote add third-remote "$(mktemp -d)" SCM_GIT_SHOW_REMOTE_INFO=false + SCM_GIT_SHOW_COMMIT_COUNT=true git_prompt_vars assert_equal "$SCM_BRANCH" "${pre}${post}" @@ -223,6 +228,7 @@ setup_repo_with_upstream() { pushd "${repo}" SCM_GIT_SHOW_REMOTE_INFO=true + SCM_GIT_SHOW_COMMIT_COUNT=true git_prompt_vars assert_equal "$SCM_BRANCH" "${pre} → my-remote${post}" From 33239845940dbe616d3c250ad622b404a0295aa3 Mon Sep 17 00:00:00 2001 From: Lowie Huyghe Date: Mon, 22 Jul 2019 16:42:29 +0200 Subject: [PATCH 03/32] Completely ignore enabled-dir in root to support symlinking. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6fad6279..a17b6e82 100755 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ bats *.sublime-workspace *.sublime-project enabled/* +/enabled tmp/ From 4c0a51aee25238f8db32271a51958f2cf358ef80 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Mon, 15 Jul 2019 09:31:16 -0300 Subject: [PATCH 04/32] Optimize SCM checks --- themes/base.theme.bash | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 430fb60d..e172dd0c 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -79,15 +79,20 @@ RBENV_THEME_PROMPT_SUFFIX='|' RBFU_THEME_PROMPT_PREFIX=' |' RBFU_THEME_PROMPT_SUFFIX='|' +GIT_EXE=`which git 2> /dev/null || true` +P4_EXE=`which p4 2> /dev/null || true` +HG_EXE=`which hg 2> /dev/null || true` +SVN_EXE=`which svn 2> /dev/null || true` + function scm { if [[ "$SCM_CHECK" = false ]]; then SCM=$SCM_NONE - elif [[ -f .git/HEAD ]] && which git &> /dev/null; then SCM=$SCM_GIT - elif which git &> /dev/null && [[ -n "$(git rev-parse --is-inside-work-tree 2> /dev/null)" ]]; then SCM=$SCM_GIT - elif which p4 &> /dev/null && [[ -n "$(p4 set P4CLIENT 2> /dev/null)" ]]; then SCM=$SCM_P4 - elif [[ -d .hg ]] && which hg &> /dev/null; then SCM=$SCM_HG - elif which hg &> /dev/null && [[ -n "$(hg root 2> /dev/null)" ]]; then SCM=$SCM_HG - elif [[ -d .svn ]] && which svn &> /dev/null; then SCM=$SCM_SVN - elif which svn &> /dev/null && [[ -n "$(svn info --show-item wc-root 2>/dev/null)" ]]; then SCM=$SCM_SVN + elif [[ -f .git/HEAD ]] && [[ -x "$GIT_EXE" ]]; then SCM=$SCM_GIT + elif [[ -x "$GIT_EXE" ]] && [[ -n "$(git rev-parse --is-inside-work-tree 2> /dev/null)" ]]; then SCM=$SCM_GIT + elif [[ -x "$P4_EXE" ]] && [[ -n "$(p4 set P4CLIENT 2> /dev/null)" ]]; then SCM=$SCM_P4 + elif [[ -d .hg ]] && [[ -x "$HG_EXE" ]]; then SCM=$SCM_HG + elif [[ -x "$HG_EXE" ]] && [[ -n "$(hg root 2> /dev/null)" ]]; then SCM=$SCM_HG + elif [[ -d .svn ]] && [[ -x "$SVN_EXE" ]]; then SCM=$SCM_SVN + elif [[ -x "$SVN_EXE" ]] && [[ -n "$(svn info --show-item wc-root 2>/dev/null)" ]]; then SCM=$SCM_SVN else SCM=$SCM_NONE fi } @@ -503,4 +508,4 @@ function safe_append_prompt_command { function _save-and-reload-history() { local autosave=${1:-0} [[ $autosave -eq 1 ]] && history -a && history -c && history -r -} \ No newline at end of file +} From ef31690b07977e1cd5b9902fc37037858ea6bcd1 Mon Sep 17 00:00:00 2001 From: Arunvel Sriram Date: Sat, 27 Jul 2019 22:50:08 +0530 Subject: [PATCH 05/32] Add helper function to add all ssh private keys to agent --- plugins/available/ssh.plugin.bash | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/available/ssh.plugin.bash b/plugins/available/ssh.plugin.bash index f670b98c..51587b29 100644 --- a/plugins/available/ssh.plugin.bash +++ b/plugins/available/ssh.plugin.bash @@ -17,3 +17,10 @@ function sshlist() { awk '$1 ~ /Host$/ {for (i=2; i<=NF; i++) print $i}' ~/.ssh/config } + +function ssh-add-all() { + about 'add all ssh private keys to agent' + group 'ssh' + + grep -slR "PRIVATE" ~/.ssh | xargs ssh-add +} From 12c49bd22fc1f1cbe9d48bc969661b0abaffe5d3 Mon Sep 17 00:00:00 2001 From: Martin Lariz Date: Mon, 29 Jul 2019 07:07:58 -0700 Subject: [PATCH 06/32] Remove errors if plugin executable not available --- plugins/available/node.plugin.bash | 2 +- plugins/available/pyenv.plugin.bash | 2 +- plugins/available/rbenv.plugin.bash | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/available/node.plugin.bash b/plugins/available/node.plugin.bash index f0467cef..597875ee 100644 --- a/plugins/available/node.plugin.bash +++ b/plugins/available/node.plugin.bash @@ -4,4 +4,4 @@ about-plugin 'Node.js helper functions' pathmunge ./node_modules/.bin # Make sure the global npm prefix is on the path -[[ `which npm` ]] && pathmunge $(npm config get prefix)/bin +[[ `which npm 2>/dev/null` ]] && pathmunge $(npm config get prefix)/bin diff --git a/plugins/available/pyenv.plugin.bash b/plugins/available/pyenv.plugin.bash index dced31a8..4d8db4fb 100644 --- a/plugins/available/pyenv.plugin.bash +++ b/plugins/available/pyenv.plugin.bash @@ -4,7 +4,7 @@ about-plugin 'load pyenv, if you are using it' export PYENV_ROOT="$HOME/.pyenv" pathmunge "$PYENV_ROOT/bin" -[[ `which pyenv` ]] && eval "$(pyenv init - bash)" +[[ `which pyenv 2>/dev/null` ]] && eval "$(pyenv init - bash)" #Load pyenv virtualenv if the virtualenv plugin is installed. if pyenv virtualenv-init - &> /dev/null; then diff --git a/plugins/available/rbenv.plugin.bash b/plugins/available/rbenv.plugin.bash index ecba0c89..2b01669d 100644 --- a/plugins/available/rbenv.plugin.bash +++ b/plugins/available/rbenv.plugin.bash @@ -4,4 +4,4 @@ about-plugin 'load rbenv, if you are using it' export RBENV_ROOT="$HOME/.rbenv" pathmunge "$RBENV_ROOT/bin" -[[ `which rbenv` ]] && eval "$(rbenv init - bash)" +[[ `which rbenv 2>/dev/null` ]] && eval "$(rbenv init - bash)" From 9735ad7b5ce4cf39567d025d2136d05f0fa3f3ad Mon Sep 17 00:00:00 2001 From: Brandon Waskiewicz Date: Mon, 29 Jul 2019 14:07:34 -0400 Subject: [PATCH 07/32] Ensure node paths are appended to existing $PATH --- plugins/available/node.plugin.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/available/node.plugin.bash b/plugins/available/node.plugin.bash index f0467cef..b012742d 100644 --- a/plugins/available/node.plugin.bash +++ b/plugins/available/node.plugin.bash @@ -1,7 +1,7 @@ cite about-plugin about-plugin 'Node.js helper functions' -pathmunge ./node_modules/.bin +pathmunge "./node_modules/.bin" "after" # Make sure the global npm prefix is on the path -[[ `which npm` ]] && pathmunge $(npm config get prefix)/bin +[[ `which npm` ]] && pathmunge "$(npm config get prefix)/bin" "after" From 1de985c460e152831f64a7e1e2c37c40d741b8e8 Mon Sep 17 00:00:00 2001 From: Jacob Hrbek Date: Tue, 30 Jul 2019 11:09:17 +0200 Subject: [PATCH 08/32] themes/agnoster : initial Initial commit of agnoster theme. Credit: Isaac "Agnoster" Wolkerstorfer https://github.com/agnoster - original creator Credit: Kenny Root https://gist.github.com/kruton/8345450 coverted from zsh to bash Credit: Toan Nguyen https://github.com/nntoan published in ohmybash/oh-my-bash (https://github.com/ohmybash/oh-my-bash) Credit: https://github.com/speedenator patch for kruton's work and maintainance. Credit: Hanish K H Updated & fixed on oct-05-2017 --- themes/agnoster/agnoster.theme.bash | 423 ++++++++++++++++++++++++++++ 1 file changed, 423 insertions(+) create mode 100644 themes/agnoster/agnoster.theme.bash diff --git a/themes/agnoster/agnoster.theme.bash b/themes/agnoster/agnoster.theme.bash new file mode 100644 index 00000000..dae991cf --- /dev/null +++ b/themes/agnoster/agnoster.theme.bash @@ -0,0 +1,423 @@ +#!/usr/bin/env bash +# vim: ft=bash ts=2 sw=2 sts=2 +# +# agnoster's Theme - https://gist.github.com/3712874 +# A Powerline-inspired theme for BASH +# +# (Converted from ZSH theme by Kenny Root) +# https://gist.github.com/kruton/8345450 +# +# Updated & fixed by Erik Selberg erik@selberg.org 1/14/17 +# Tested on MacOSX, Ubuntu, Amazon Linux +# Bash v3 and v4 +# +# # README +# +# In order for this theme to render correctly, you will need a +# [Powerline-patched font](https://gist.github.com/1595572). +# I recommend: https://github.com/powerline/fonts.git +# > git clone https://github.com/powerline/fonts.git fonts +# > cd fonts +# > install.sh + +# In addition, I recommend the +# [Solarized theme](https://github.com/altercation/solarized/) and, if you're +# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app - +# it has significantly better color fidelity. + +# Install: + +# I recommend the following: +# $ cd home +# $ mkdir -p .bash/themes/agnoster-bash +# $ git clone https://github.com/speedenator/agnoster-bash.git .bash/themes/agnoster-bash + +# then add the following to your .bashrc: + +# export THEME=$HOME/.bash/themes/agnoster-bash/agnoster.bash +# if [[ -f $THEME ]]; then +# export DEFAULT_USER=`whoami` +# source $THEME +# fi + +# +# # Goals +# +# The aim of this theme is to only show you *relevant* information. Like most +# prompts, it will only show git information when in a git working directory. +# However, it goes a step further: everything from the current user and +# hostname to whether the last call exited with an error to whether background +# jobs are running in this shell will all be displayed automatically when +# appropriate. + +# Generally speaking, this script has limited support for right +# prompts (ala powerlevel9k on zsh), but it's pretty problematic in Bash. +# The general pattern is to write out the right prompt, hit \r, then +# write the left. This is problematic for the following reasons: +# - Doesn't properly resize dynamically when you resize the terminal +# - Changes to the prompt (like clearing and re-typing, super common) deletes the prompt +# - Getting the right alignment via columns / tput cols is pretty problematic (and is a bug in this version) +# - Bash prompt escapes (like \h or \w) don't get interpolated +# +# all in all, if you really, really want right-side prompts without a +# ton of work, recommend going to zsh for now. If you know how to fix this, +# would appreciate it! + +# note: requires bash v4+... Mac users - you often have bash3. +# 'brew install bash' will set you free +PROMPT_DIRTRIM=2 # bash4 and above + +###################################################################### +DEBUG=0 +debug() { + if [[ ${DEBUG} -ne 0 ]]; then + >&2 echo -e $* + fi +} + +###################################################################### +### Segment drawing +# A few utility functions to make it easy and re-usable to draw segmented prompts + +CURRENT_BG='NONE' +CURRENT_RBG='NONE' +SEGMENT_SEPARATOR='' +RIGHT_SEPARATOR='' +LEFT_SUBSEG='' +RIGHT_SUBSEG='' + +text_effect() { + case "$1" in + reset) echo 0;; + bold) echo 1;; + underline) echo 4;; + esac +} + +# to add colors, see +# http://bitmote.com/index.php?post/2012/11/19/Using-ANSI-Color-Codes-to-Colorize-Your-Bash-Prompt-on-Linux +# under the "256 (8-bit) Colors" section, and follow the example for orange below +fg_color() { + case "$1" in + black) echo 30;; + red) echo 31;; + green) echo 32;; + yellow) echo 33;; + blue) echo 34;; + magenta) echo 35;; + cyan) echo 36;; + white) echo 37;; + orange) echo 38\;5\;166;; + esac +} + +bg_color() { + case "$1" in + black) echo 40;; + red) echo 41;; + green) echo 42;; + yellow) echo 43;; + blue) echo 44;; + magenta) echo 45;; + cyan) echo 46;; + white) echo 47;; + orange) echo 48\;5\;166;; + esac; +} + +# TIL: declare is global not local, so best use a different name +# for codes (mycodes) as otherwise it'll clobber the original. +# this changes from BASH v3 to BASH v4. +ansi() { + local seq + declare -a mycodes=("${!1}") + + debug "ansi: ${!1} all: $* aka ${mycodes[@]}" + + seq="" + for ((i = 0; i < ${#mycodes[@]}; i++)); do + if [[ -n $seq ]]; then + seq="${seq};" + fi + seq="${seq}${mycodes[$i]}" + done + debug "ansi debug:" '\\[\\033['${seq}'m\\]' + echo -ne '\[\033['${seq}'m\]' + # PR="$PR\[\033[${seq}m\]" +} + +ansi_single() { + echo -ne '\[\033['$1'm\]' +} + +# Begin a segment +# Takes two arguments, background and foreground. Both can be omitted, +# rendering default background/foreground. +prompt_segment() { + local bg fg + declare -a codes + + debug "Prompting $1 $2 $3" + + # if commented out from kruton's original... I'm not clear + # if it did anything, but it messed up things like + # prompt_status - Erik 1/14/17 + + # if [[ -z $1 || ( -z $2 && $2 != default ) ]]; then + codes=("${codes[@]}" $(text_effect reset)) + # fi + if [[ -n $1 ]]; then + bg=$(bg_color $1) + codes=("${codes[@]}" $bg) + debug "Added $bg as background to codes" + fi + if [[ -n $2 ]]; then + fg=$(fg_color $2) + codes=("${codes[@]}" $fg) + debug "Added $fg as foreground to codes" + fi + + debug "Codes: " + # declare -p codes + + if [[ $CURRENT_BG != NONE && $1 != $CURRENT_BG ]]; then + declare -a intermediate=($(fg_color $CURRENT_BG) $(bg_color $1)) + debug "pre prompt " $(ansi intermediate[@]) + PR="$PR $(ansi intermediate[@])$SEGMENT_SEPARATOR" + debug "post prompt " $(ansi codes[@]) + PR="$PR$(ansi codes[@]) " + else + debug "no current BG, codes is $codes[@]" + PR="$PR$(ansi codes[@]) " + fi + CURRENT_BG=$1 + [[ -n $3 ]] && PR="$PR$3" +} + +# End the prompt, closing any open segments +prompt_end() { + if [[ -n $CURRENT_BG ]]; then + declare -a codes=($(text_effect reset) $(fg_color $CURRENT_BG)) + PR="$PR $(ansi codes[@])$SEGMENT_SEPARATOR" + fi + declare -a reset=($(text_effect reset)) + PR="$PR $(ansi reset[@])" + CURRENT_BG='' +} + +### virtualenv prompt +prompt_virtualenv() { + if [[ -n $VIRTUAL_ENV ]]; then + color=cyan + prompt_segment $color $PRIMARY_FG + prompt_segment $color white "$(basename $VIRTUAL_ENV)" + fi +} + + +### Prompt components +# Each component will draw itself, and hide itself if no information needs to be shown + +# Context: user@hostname (who am I and where am I) +prompt_context() { + local user=`whoami` + + if [[ $user != $DEFAULT_USER || -n $SSH_CLIENT ]]; then + prompt_segment black default "$user@\h" + fi +} + +# prints history followed by HH:MM, useful for remembering what +# we did previously +prompt_histdt() { + prompt_segment black default "\! [\A]" +} + + +git_status_dirty() { + dirty=$(git status -s 2> /dev/null | tail -n 1) + [[ -n $dirty ]] && echo " ●" +} + +# Git: branch/detached head, dirty status +prompt_git() { + local ref dirty + if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + ZSH_THEME_GIT_PROMPT_DIRTY='±' + dirty=$(git_status_dirty) + ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)" + if [[ -n $dirty ]]; then + prompt_segment yellow black + else + prompt_segment green black + fi + PR="$PR${ref/refs\/heads\// }$dirty" + fi +} + +# Dir: current working directory +prompt_dir() { + prompt_segment blue black '\w' +} + +# Status: +# - was there an error +# - am I root +# - are there background jobs? +prompt_status() { + local symbols + symbols=() + [[ $RETVAL -ne 0 ]] && symbols+="$(ansi_single $(fg_color red))✘" + [[ $UID -eq 0 ]] && symbols+="$(ansi_single $(fg_color yellow))⚡" + [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="$(ansi_single $(fg_color cyan))⚙" + + [[ -n "$symbols" ]] && prompt_segment black default "$symbols" +} + +###################################################################### +# +# experimental right prompt stuff +# requires setting prompt_foo to use PRIGHT vs PR +# doesn't quite work per above + +rightprompt() { + printf "%*s" $COLUMNS "$PRIGHT" +} + +# quick right prompt I grabbed to test things. +__command_rprompt() { + local times= n=$COLUMNS tz + for tz in ZRH:Europe/Zurich PIT:US/Eastern \ + MTV:US/Pacific TOK:Asia/Tokyo; do + [ $n -gt 40 ] || break + times="$times ${tz%%:*}\e[30;1m:\e[0;36;1m" + times="$times$(TZ=${tz#*:} date +%H:%M)\e[0m" + n=$(( $n - 10 )) + done + [ -z "$times" ] || printf "%${n}s$times\\r" '' +} +# PROMPT_COMMAND=__command_rprompt + +# this doens't wrap code in \[ \] +ansi_r() { + local seq + declare -a mycodes2=("${!1}") + + debug "ansi: ${!1} all: $* aka ${mycodes2[@]}" + + seq="" + for ((i = 0; i < ${#mycodes2[@]}; i++)); do + if [[ -n $seq ]]; then + seq="${seq};" + fi + seq="${seq}${mycodes2[$i]}" + done + debug "ansi debug:" '\\[\\033['${seq}'m\\]' + echo -ne '\033['${seq}'m' + # PR="$PR\[\033[${seq}m\]" +} + +# Begin a segment on the right +# Takes two arguments, background and foreground. Both can be omitted, +# rendering default background/foreground. +prompt_right_segment() { + local bg fg + declare -a codes + + debug "Prompt right" + debug "Prompting $1 $2 $3" + + # if commented out from kruton's original... I'm not clear + # if it did anything, but it messed up things like + # prompt_status - Erik 1/14/17 + + # if [[ -z $1 || ( -z $2 && $2 != default ) ]]; then + codes=("${codes[@]}" $(text_effect reset)) + # fi + if [[ -n $1 ]]; then + bg=$(bg_color $1) + codes=("${codes[@]}" $bg) + debug "Added $bg as background to codes" + fi + if [[ -n $2 ]]; then + fg=$(fg_color $2) + codes=("${codes[@]}" $fg) + debug "Added $fg as foreground to codes" + fi + + debug "Right Codes: " + # declare -p codes + + # right always has a separator + # if [[ $CURRENT_RBG != NONE && $1 != $CURRENT_RBG ]]; then + # $CURRENT_RBG= + # fi + declare -a intermediate2=($(fg_color $1) $(bg_color $CURRENT_RBG) ) + # PRIGHT="$PRIGHT---" + debug "pre prompt " $(ansi_r intermediate2[@]) + PRIGHT="$PRIGHT$(ansi_r intermediate2[@])$RIGHT_SEPARATOR" + debug "post prompt " $(ansi_r codes[@]) + PRIGHT="$PRIGHT$(ansi_r codes[@]) " + # else + # debug "no current BG, codes is $codes[@]" + # PRIGHT="$PRIGHT$(ansi codes[@]) " + # fi + CURRENT_RBG=$1 + [[ -n $3 ]] && PRIGHT="$PRIGHT$3" +} + +###################################################################### +## Emacs prompt --- for dir tracking +# stick the following in your .emacs if you use this: + +# (setq dirtrack-list '(".*DIR *\\([^ ]*\\) DIR" 1 nil)) +# (defun dirtrack-filter-out-pwd-prompt (string) +# "dirtrack-mode doesn't remove the PWD match from the prompt. This does." +# ;; TODO: support dirtrack-mode's multiline regexp. +# (if (and (stringp string) (string-match (first dirtrack-list) string)) +# (replace-match "" t t string 0) +# string)) +# (add-hook 'shell-mode-hook +# #'(lambda () +# (dirtrack-mode 1) +# (add-hook 'comint-preoutput-filter-functions +# 'dirtrack-filter-out-pwd-prompt t t))) + +prompt_emacsdir() { + # no color or other setting... this will be deleted per above + PR="DIR \w DIR$PR" +} + +###################################################################### +## Main prompt + +build_prompt() { + [[ ! -z ${AG_EMACS_DIR+x} ]] && prompt_emacsdir + prompt_status + #[[ -z ${AG_NO_HIST+x} ]] && prompt_histdt + [[ -z ${AG_NO_CONTEXT+x} ]] && prompt_context + prompt_virtualenv + prompt_dir + prompt_git + prompt_end +} + +# from orig... +# export PS1='$(ansi_single $(text_effect reset)) $(build_prompt) ' +# this doesn't work... new model: create a prompt via a PR variable and +# use that. + +set_bash_prompt() { + RETVAL=$? + PR="" + PRIGHT="" + CURRENT_BG=NONE + PR="$(ansi_single $(text_effect reset))" + build_prompt + + # uncomment below to use right prompt + # PS1='\[$(tput sc; printf "%*s" $COLUMNS "$PRIGHT"; tput rc)\]'$PR + PS1=$PR +} + +PROMPT_COMMAND=set_bash_prompt From f29a195f49be108595ff41e858af70c3821ca7d7 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Wed, 31 Jul 2019 08:49:20 +0200 Subject: [PATCH 09/32] Make sed replacements work for both BSD and GNU sed Fixes #1411 --- lib/helpers.bash | 10 ++++++++++ plugins/available/proxy.plugin.bash | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index 3a47cd4a..e7ef15ba 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -5,6 +5,16 @@ BASH_IT_LOAD_PRIORITY_DEFAULT_PLUGIN=${BASH_IT_LOAD_PRIORITY_DEFAULT_PLUGIN:-250 BASH_IT_LOAD_PRIORITY_DEFAULT_COMPLETION=${BASH_IT_LOAD_PRIORITY_DEFAULT_COMPLETION:-350} BASH_IT_LOAD_PRIORITY_SEPARATOR="---" +# Handle the different ways of running `sed` without generating a backup file based on OS +# - GNU sed (Linux) uses `-i` +# - BSD sed (macOS) uses `-i ''` +# To use this in Bash-it for inline replacements with `sed`, use the following syntax: +# sed "${BASH_IT_SED_I_PARAMETERS[@]}" -e "..." file +BASH_IT_SED_I_PARAMETERS=(-i) +case "$(uname)" in + Darwin*) BASH_IT_SED_I_PARAMETERS=(-i "") +esac + function _command_exists () { _about 'checks for existence of a command' diff --git a/plugins/available/proxy.plugin.bash b/plugins/available/proxy.plugin.bash index 4f4bcbac..afd4dba4 100644 --- a/plugins/available/proxy.plugin.bash +++ b/plugins/available/proxy.plugin.bash @@ -370,7 +370,7 @@ ssh-disable-proxy () group 'proxy' if [ -f ~/.ssh/config ] ; then - sed -e's/^.*ProxyCommand/# ProxyCommand/' -i "" ~/.ssh/config + sed -e's/^.*ProxyCommand/# ProxyCommand/' "${BASH_IT_SED_I_PARAMETERS[@]}" ~/.ssh/config echo "Disabled SSH config proxy settings" fi } @@ -382,7 +382,7 @@ ssh-enable-proxy () group 'proxy' if [ -f ~/.ssh/config ] ; then - sed -e's/# ProxyCommand/ ProxyCommand/' -i "" ~/.ssh/config + sed -e's/# ProxyCommand/ ProxyCommand/' "${BASH_IT_SED_I_PARAMETERS[@]}" ~/.ssh/config echo "Enabled SSH config proxy settings" fi } From c4d03f2407016bfac08f896493d3c24c5b8aa9c7 Mon Sep 17 00:00:00 2001 From: Zhao Li Date: Fri, 30 Aug 2019 15:37:17 -1000 Subject: [PATCH 10/32] note how to use toggle flag in README --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 13a991da..92b6465d 100644 --- a/README.md +++ b/README.md @@ -329,6 +329,19 @@ Set `SCM_GIT_SHOW_STASH_INFO` to 'false' to **don't show** it: * `export SCM_GIT_SHOW_STASH_INFO=false` +### Ahead/Behind Count + +When displaying information regarding whether or not the local branch is ahead or behind it's remote counterpart, you can opt to display the number of commits ahead/behind. +This is useful if you only care whether or not you are ahead or behind and do not care how far ahead/behind you are. + +Set `SCM_GIT_SHOW_COMMIT_COUNT` to 'true' (the default value) to **show** the count of commits ahead/behind: + +* `export SCM_GIT_SHOW_COMMIT_COUNT=true` + +Set `SCM_GIT_SHOW_COMMIT_COUNT` to 'false' to **don't show** it: + +* `export SCM_GIT_SHOW_COMMIT_COUNT=false` + ### Git user In some environments, it is useful to know the value of the current git user, which is used to mark all new commits. From a0af4f40cd72f5cc39ac3139c674a801f34056bf Mon Sep 17 00:00:00 2001 From: Stefano Cislaghi Date: Mon, 2 Sep 2019 11:40:51 +0100 Subject: [PATCH 11/32] Added proxy exceptions (noproxy) for npm --- plugins/available/proxy.plugin.bash | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/available/proxy.plugin.bash b/plugins/available/proxy.plugin.bash index afd4dba4..f2458e3f 100644 --- a/plugins/available/proxy.plugin.bash +++ b/plugins/available/proxy.plugin.bash @@ -121,6 +121,7 @@ npm-show-proxy () echo "===" echo "npm HTTP proxy: " `npm config get proxy` echo "npm HTTPS proxy: " `npm config get https-proxy` + echo "npm proxy exceptions: " `npm config get noproxy` fi } @@ -132,6 +133,7 @@ npm-disable-proxy () if $(command -v npm &> /dev/null) ; then npm config delete proxy npm config delete https-proxy + npm config delete noproxy echo "Disabled npm proxy settings" fi } @@ -143,10 +145,12 @@ npm-enable-proxy () local my_http_proxy=${1:-$BASH_IT_HTTP_PROXY} local my_https_proxy=${2:-$BASH_IT_HTTPS_PROXY} + local my_no_proxy=${3:-$BASH_IT_NO_PROXY} if $(command -v npm &> /dev/null) ; then npm config set proxy $my_http_proxy npm config set https-proxy $my_https_proxy + npm config set noproxy $my_no_proxy echo "Enabled npm proxy settings" fi } From 4b2812cbdf3872e8f9f64fff659d29a70b70208f Mon Sep 17 00:00:00 2001 From: Stanko Date: Fri, 13 Sep 2019 10:57:01 +0200 Subject: [PATCH 12/32] Trivial fix for clean theme --- themes/clean/clean.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/clean/clean.theme.bash b/themes/clean/clean.theme.bash index c479a041..0082d671 100644 --- a/themes/clean/clean.theme.bash +++ b/themes/clean/clean.theme.bash @@ -13,7 +13,7 @@ function prompt_command() { if [ "$(whoami)" = root ]; then no_color=$red; else no_color=$white; fi - PS1="${no_color}\u${reset_color}:${blue}\W/${reset_color} \[$(scm_prompt_info)\]${normal}$ " + PS1="${no_color}\u${reset_color}:${blue}\W/${reset_color} $(scm_prompt_info)${normal}$ " } safe_append_prompt_command prompt_command From 92d7e29125454a60953e4a977f245403418a27ac Mon Sep 17 00:00:00 2001 From: Mattia Rigotti Date: Fri, 27 Sep 2019 14:22:01 -0400 Subject: [PATCH 13/32] Add theme/sexy-python, a modified version of sexy which shows in which virtualenv or condaenv you are --- themes/sexy-python/sexy-python.theme.bash | 46 +++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 themes/sexy-python/sexy-python.theme.bash diff --git a/themes/sexy-python/sexy-python.theme.bash b/themes/sexy-python/sexy-python.theme.bash new file mode 100644 index 00000000..e472218a --- /dev/null +++ b/themes/sexy-python/sexy-python.theme.bash @@ -0,0 +1,46 @@ +# Small modification of Sexy Bash Prompt to include virtualenv and condaenv prompts +# (Sexy Bash Prompt is inspired by "Extravagant Zsh Prompt" +# with big thanks to \amethyst on Freenode) + +if tput setaf 1 &> /dev/null; then + if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then + MAGENTA=$(tput setaf 9) + ORANGE=$(tput setaf 172) + GREEN=$(tput setaf 190) + PURPLE=$(tput setaf 141) + WHITE=$(tput setaf 0) + else + MAGENTA=$(tput setaf 5) + ORANGE=$(tput setaf 4) + GREEN=$(tput setaf 2) + PURPLE=$(tput setaf 1) + WHITE=$(tput setaf 7) + fi + BOLD=$(tput bold) + RESET=$(tput sgr0) +else + MAGENTA="\033[1;31m" + ORANGE="\033[1;33m" + GREEN="\033[1;32m" + PURPLE="\033[1;35m" + WHITE="\033[1;37m" + BOLD="" + RESET="\033[m" +fi + +parse_git_dirty () { + [[ $(git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*" +} +parse_git_branch () { + git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" +} + +env_prompt () { + echo -e "($(virtualenv_prompt)$(condaenv_prompt))" +} + +function prompt_command() { + PS1="\[${BOLD}${WHITE}\]$(env_prompt) \[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]" +} + +safe_append_prompt_command prompt_command From 1224fbb0fab3814c4161c29952ba910809773182 Mon Sep 17 00:00:00 2001 From: Jonathan Lao-kan Date: Thu, 3 Oct 2019 22:05:53 +0200 Subject: [PATCH 14/32] Improve grammar in README --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 92b6465d..ccaa7946 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Includes autocompletion, themes, aliases, custom functions, a few stolen pieces from Steve Losh, and more. Bash-it provides a solid framework for using, developing and maintaining shell scripts and custom commands for your daily work. -If you're using the _Bourne Again Shell_ (Bash) on a regular basis and have been looking for an easy way on how to keep all of these nice little scripts and aliases under control, then Bash-it is for you! +If you're using the _Bourne Again Shell_ (Bash) regularly and have been looking for an easy way on how to keep all of these nice little scripts and aliases under control, then Bash-it is for you! Stop polluting your `~/bin` directory and your `.bashrc` file, fork/clone Bash-it and start hacking away. - [Contributing](#contributing) @@ -58,7 +58,7 @@ Feel free to enable the tools you want to use after the installation. When you run without the `--no-modify-config` switch, the Bash-it installer automatically modifies/replaces your existing config file. Use the `--no-modify-config` switch to avoid unwanted modifications, e.g. if your Bash config file already contains the code that loads Bash-it. -**NOTE**: Keep in mind how Bash load its configuration files, +**NOTE**: Keep in mind how Bash loads its configuration files, `.bash_profile` for login shells (and in macOS in terminal emulators like [Terminal.app](http://www.apple.com/osx/apps/) or [iTerm2](https://www.iterm2.com/)) and `.bashrc` for interactive shells (default mode in most of the GNU/Linux terminal emulators), to ensure that Bash-it is loaded correctly. @@ -77,7 +77,7 @@ Refer to the official [Bash documentation](https://www.gnu.org/software/bash/man ### Install using Docker You can try Bash-it in an isolated environment without changing any local files via a [Docker](https://www.docker.com/) Container. -(Bash Shell v4.4 with Bash-it, [bats](https://github.com/sstephenson/bats) and bash-completion based on [Alpine Linux](https://alpinelinux.org/)). +(Bash Shell v4.4 with Bash-it, [bats](https://github.com/sstephenson/bats),and bash-completion based on [Alpine Linux](https://alpinelinux.org/)). `docker pull ellerbrock/bash-it` @@ -206,7 +206,7 @@ export BASH_IT_THEME="" You can easily preview the themes in your own shell using `BASH_PREVIEW=true bash-it reload`. -If you've created your own custom prompts, we'd love it if you shared with everyone else! Just submit a Pull Request. +If you've created your own custom prompts, we'd love it if you shared them with everyone else! Just submit a Pull Request. You can see theme screenshots on [wiki/Themes](https://github.com/Bash-it/bash-it/wiki/Themes). **NOTE**: Bash-it and some themes use UTF-8 characters, so to avoid strange behavior in your terminal, set your locale to `LC_ALL=en_US.UTF-8` or the equivalent to your language if it isn't American English. @@ -235,7 +235,7 @@ Bash-it will automatically reload itself after activating or deactivating plugin ### Prompt Version Control Check -Bash-it provides prompt themes the ability to check and display version control information for the current directory. +Bash-it provides prompt themes with the ability to check and display version control information for the current directory. The information is retrieved for each directory and can slow down the navigation of projects with a large number of files and folders. Turn version control checking off to prevent slow directory navigation within large projects. @@ -331,7 +331,7 @@ Set `SCM_GIT_SHOW_STASH_INFO` to 'false' to **don't show** it: ### Ahead/Behind Count -When displaying information regarding whether or not the local branch is ahead or behind it's remote counterpart, you can opt to display the number of commits ahead/behind. +When displaying information regarding whether or not the local branch is ahead or behind its remote counterpart, you can opt to display the number of commits ahead/behind. This is useful if you only care whether or not you are ahead or behind and do not care how far ahead/behind you are. Set `SCM_GIT_SHOW_COMMIT_COUNT` to 'true' (the default value) to **show** the count of commits ahead/behind: From 8b7333cd299135ce175d293d495f12ccf0a0377f Mon Sep 17 00:00:00 2001 From: Mattia Rigotti Date: Fri, 27 Sep 2019 14:22:01 -0400 Subject: [PATCH 15/32] Add theme/sexy-python, a modified version of sexy which shows in which virtualenv or condaenv you are --- themes/sexy-python/sexy-python.theme.bash | 46 +++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 themes/sexy-python/sexy-python.theme.bash diff --git a/themes/sexy-python/sexy-python.theme.bash b/themes/sexy-python/sexy-python.theme.bash new file mode 100644 index 00000000..e472218a --- /dev/null +++ b/themes/sexy-python/sexy-python.theme.bash @@ -0,0 +1,46 @@ +# Small modification of Sexy Bash Prompt to include virtualenv and condaenv prompts +# (Sexy Bash Prompt is inspired by "Extravagant Zsh Prompt" +# with big thanks to \amethyst on Freenode) + +if tput setaf 1 &> /dev/null; then + if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then + MAGENTA=$(tput setaf 9) + ORANGE=$(tput setaf 172) + GREEN=$(tput setaf 190) + PURPLE=$(tput setaf 141) + WHITE=$(tput setaf 0) + else + MAGENTA=$(tput setaf 5) + ORANGE=$(tput setaf 4) + GREEN=$(tput setaf 2) + PURPLE=$(tput setaf 1) + WHITE=$(tput setaf 7) + fi + BOLD=$(tput bold) + RESET=$(tput sgr0) +else + MAGENTA="\033[1;31m" + ORANGE="\033[1;33m" + GREEN="\033[1;32m" + PURPLE="\033[1;35m" + WHITE="\033[1;37m" + BOLD="" + RESET="\033[m" +fi + +parse_git_dirty () { + [[ $(git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*" +} +parse_git_branch () { + git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" +} + +env_prompt () { + echo -e "($(virtualenv_prompt)$(condaenv_prompt))" +} + +function prompt_command() { + PS1="\[${BOLD}${WHITE}\]$(env_prompt) \[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]" +} + +safe_append_prompt_command prompt_command From b0a22e0b97b0234655a78cbc44d8bbedc0f6397d Mon Sep 17 00:00:00 2001 From: Mattia Rigotti Date: Fri, 4 Oct 2019 12:50:06 -0400 Subject: [PATCH 16/32] In themes/sexy add option to visualize python environment --- themes/sexy/sexy.theme.bash | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/themes/sexy/sexy.theme.bash b/themes/sexy/sexy.theme.bash index 08869a3b..4250c540 100644 --- a/themes/sexy/sexy.theme.bash +++ b/themes/sexy/sexy.theme.bash @@ -1,6 +1,10 @@ # Sexy Bash Prompt, inspired by "Extravagant Zsh Prompt" # Screenshot: http://cloud.gf3.ca/M5rG # A big thanks to \amethyst on Freenode +# +# Configuration: +# * To visualize python environment (virtualenv and conda) add in your .bash_profile the following line: +# export SEXY_WITH_PYTHON=true if tput setaf 1 &> /dev/null; then if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then @@ -34,9 +38,16 @@ parse_git_dirty () { parse_git_branch () { git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" } +env_prompt () { + echo -e "($(virtualenv_prompt)$(condaenv_prompt))" +} function prompt_command() { PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]" + + if [ "$SEXY_WITH_PYTHON" = true ] ; then + PS1="\[${BOLD}${WHITE}\]$(env_prompt) "$PS1 + fi } safe_append_prompt_command prompt_command From ed47edcb06079642ee1e28ea0ea46d7b9005c4e4 Mon Sep 17 00:00:00 2001 From: Mattia Rigotti Date: Fri, 4 Oct 2019 12:51:23 -0400 Subject: [PATCH 17/32] Remove themes/sexy-python (it is now integrated in themes/sexy) --- themes/sexy-python/sexy-python.theme.bash | 46 ----------------------- 1 file changed, 46 deletions(-) delete mode 100644 themes/sexy-python/sexy-python.theme.bash diff --git a/themes/sexy-python/sexy-python.theme.bash b/themes/sexy-python/sexy-python.theme.bash deleted file mode 100644 index e472218a..00000000 --- a/themes/sexy-python/sexy-python.theme.bash +++ /dev/null @@ -1,46 +0,0 @@ -# Small modification of Sexy Bash Prompt to include virtualenv and condaenv prompts -# (Sexy Bash Prompt is inspired by "Extravagant Zsh Prompt" -# with big thanks to \amethyst on Freenode) - -if tput setaf 1 &> /dev/null; then - if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then - MAGENTA=$(tput setaf 9) - ORANGE=$(tput setaf 172) - GREEN=$(tput setaf 190) - PURPLE=$(tput setaf 141) - WHITE=$(tput setaf 0) - else - MAGENTA=$(tput setaf 5) - ORANGE=$(tput setaf 4) - GREEN=$(tput setaf 2) - PURPLE=$(tput setaf 1) - WHITE=$(tput setaf 7) - fi - BOLD=$(tput bold) - RESET=$(tput sgr0) -else - MAGENTA="\033[1;31m" - ORANGE="\033[1;33m" - GREEN="\033[1;32m" - PURPLE="\033[1;35m" - WHITE="\033[1;37m" - BOLD="" - RESET="\033[m" -fi - -parse_git_dirty () { - [[ $(git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*" -} -parse_git_branch () { - git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" -} - -env_prompt () { - echo -e "($(virtualenv_prompt)$(condaenv_prompt))" -} - -function prompt_command() { - PS1="\[${BOLD}${WHITE}\]$(env_prompt) \[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]" -} - -safe_append_prompt_command prompt_command From c0ac3d8393bfe6328f3e10b09734dc2f2a94465c Mon Sep 17 00:00:00 2001 From: markusdd Date: Sat, 5 Oct 2019 15:50:59 +0200 Subject: [PATCH 18/32] Update less-pretty-cat plugin to support pygment style selection Pygments offers great styles and in dark terminals the default is unsatisfactory. Use two new env variables BASH_IT_CLESS_STYLE and BASH_IT_CCAT_STYLE to select pygment themes. Availables styles can be listes using pygmentize -L styles --- plugins/available/less-pretty-cat.plugin.bash | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/available/less-pretty-cat.plugin.bash b/plugins/available/less-pretty-cat.plugin.bash index 841122ca..ce846868 100644 --- a/plugins/available/less-pretty-cat.plugin.bash +++ b/plugins/available/less-pretty-cat.plugin.bash @@ -13,9 +13,12 @@ if $(command -v pygmentize &> /dev/null) ; then about 'runs either pygmentize or cat on each file passed in' param '*: files to concatenate (as normally passed to cat)' example 'cat mysite/manage.py dir/text-file.txt' + if [ -z "$BASH_IT_CCAT_STYLE" ]; then + BASH_IT_CCAT_STYLE=default; + fi for var; do - pygmentize "$var" 2>/dev/null || "$CAT_BIN" "$var"; + pygmentize -f 256 -O style="$BASH_IT_CCAT_STYLE" -g "$var" 2>/dev/null || "$CAT_BIN" "$var"; done } @@ -24,6 +27,9 @@ if $(command -v pygmentize &> /dev/null) ; then about 'it pigments the file passed in and passes it to less for pagination' param '$1: the file to paginate with less' example 'less mysite/manage.py' - pygmentize -g $* | "$LESS_BIN" -R + if [ -z "$BASH_IT_CLESS_STYLE" ]; then + BASH_IT_CLESS_STYLE=default; + fi + pygmentize -f 256 -O style="$BASH_IT_CLESS_STYLE" -g $* | "$LESS_BIN" -R } fi From c9054e25a9c847eee4a8af27e47af2deec75bf28 Mon Sep 17 00:00:00 2001 From: markusdd Date: Mon, 7 Oct 2019 14:19:38 +0200 Subject: [PATCH 19/32] implement feedback --- plugins/available/less-pretty-cat.plugin.bash | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/plugins/available/less-pretty-cat.plugin.bash b/plugins/available/less-pretty-cat.plugin.bash index ce846868..b6b9d1f0 100644 --- a/plugins/available/less-pretty-cat.plugin.bash +++ b/plugins/available/less-pretty-cat.plugin.bash @@ -5,6 +5,8 @@ if $(command -v pygmentize &> /dev/null) ; then # get the full paths to binaries CAT_BIN=$(which cat) LESS_BIN=$(which less) + BASH_IT_CCAT_STYLE="${BASH_IT_CCAT_STYLE:=default}" + BASH_IT_CLESS_STYLE="${BASH_IT_CLESS_STYLE:=default}" # pigmentize cat and less outputs - call them ccat and cless to avoid that # especially cat'ed output in scripts gets mangled with pygemtized meta characters @@ -13,9 +15,6 @@ if $(command -v pygmentize &> /dev/null) ; then about 'runs either pygmentize or cat on each file passed in' param '*: files to concatenate (as normally passed to cat)' example 'cat mysite/manage.py dir/text-file.txt' - if [ -z "$BASH_IT_CCAT_STYLE" ]; then - BASH_IT_CCAT_STYLE=default; - fi for var; do pygmentize -f 256 -O style="$BASH_IT_CCAT_STYLE" -g "$var" 2>/dev/null || "$CAT_BIN" "$var"; @@ -27,9 +26,6 @@ if $(command -v pygmentize &> /dev/null) ; then about 'it pigments the file passed in and passes it to less for pagination' param '$1: the file to paginate with less' example 'less mysite/manage.py' - if [ -z "$BASH_IT_CLESS_STYLE" ]; then - BASH_IT_CLESS_STYLE=default; - fi pygmentize -f 256 -O style="$BASH_IT_CLESS_STYLE" -g $* | "$LESS_BIN" -R } fi From ea02e3d6bd3ad603224cacb5ee7b56583dd6b693 Mon Sep 17 00:00:00 2001 From: Zanark Date: Thu, 10 Oct 2019 16:54:43 +0530 Subject: [PATCH 20/32] added theme bash files --- themes/gitline/powerline.base.bash | 234 +++++++++++++++++++++++++++++ themes/gitline/redline.theme.bash | 68 +++++++++ 2 files changed, 302 insertions(+) create mode 100644 themes/gitline/powerline.base.bash create mode 100644 themes/gitline/redline.theme.bash diff --git a/themes/gitline/powerline.base.bash b/themes/gitline/powerline.base.bash new file mode 100644 index 00000000..925791fc --- /dev/null +++ b/themes/gitline/powerline.base.bash @@ -0,0 +1,234 @@ +# Define this here so it can be used by all of the Powerline themes +THEME_CHECK_SUDO=${THEME_CHECK_SUDO:=true} + +#To set color for foreground and background +function set_color { + set +u + if [[ "${1}" != "-" ]]; then + fg="38;5;${1}" + fi + if [[ "${2}" != "-" ]]; then + bg="48;5;${2}" + [[ -n "${fg}" ]] && bg=";${bg}" + fi + echo -e "\[\033[${fg}${bg}m\]" +} + +#Customising User Info Segment +function __powerline_user_info_prompt { + local user_info="${USER}" + local color=${USER_INFO_THEME_PROMPT_COLOR} + local fg_color=15 + + if [[ "${THEME_CHECK_SUDO}" = true ]]; then + if sudo -n uptime 2>&1 | grep -q "load"; then + color=${USER_INFO_THEME_PROMPT_COLOR_SUDO} + fi + fi + + case "${POWERLINE_PROMPT_USER_INFO_MODE}" in + "sudo") + if [[ "${color}" = "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]]; then + user_info="👑 ${USER}" + fg_color=227 + color=${USER_INFO_THEME_PROMPT_COLOR_SUDO} + fi + ;; + *) + if [[ -n "${SSH_CLIENT}" ]] || [[ -n "${SSH_CONNECTION}" ]]; then + user_info="${USER_INFO_SSH_CHAR}${USER}" + else + user_info="${USER}" + fi + ;; + esac + [[ -n "${user_info}" ]] && echo "${user_info}|${color}|${fg_color}" +} + +#Customising Ruby Prompt +function __powerline_ruby_prompt { + local ruby_version="" + local fg_color=206 + + if _command_exists rvm; then + ruby_version="$(rvm_version_prompt)" + elif _command_exists rbenv; then + ruby_version=$(rbenv_version_prompt) + fi + + [[ -n "${ruby_version}" ]] && echo "${RUBY_CHAR}${ruby_version}|${RUBY_THEME_PROMPT_COLOR}|${fg_color}" +} + +#Customising Python (venv) Prompt +function __powerline_python_venv_prompt { + set +u + local python_venv="" + local fg_color=206 + + if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then + python_venv="${CONDA_DEFAULT_ENV}" + PYTHON_VENV_CHAR=${CONDA_PYTHON_VENV_CHAR} + elif [[ -n "${VIRTUAL_ENV}" ]]; then + python_venv=$(basename "${VIRTUAL_ENV}") + fi + + [[ -n "${python_venv}" ]] && echo "${PYTHON_VENV_CHAR}${python_venv}|${PYTHON_VENV_THEME_PROMPT_COLOR}|${fg_color}" +} + +#Customising SCM Prompt +function __powerline_scm_prompt { + local color="" + local scm_prompt="" + local fg_color=206 + + scm_prompt_vars + + # echo "${scm}" + + if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then + if [[ "${SCM_DIRTY}" -eq 3 ]]; then + color=${SCM_THEME_PROMPT_STAGED_COLOR} + fg_color=124 + elif [[ "${SCM_DIRTY}" -eq 2 ]]; then + color=${SCM_THEME_PROMPT_UNSTAGED_COLOR} + fg_color=56 + elif [[ "${SCM_DIRTY}" -eq 1 ]]; then + color=${SCM_THEME_PROMPT_DIRTY_COLOR} + fg_color=118 + elif [[ "${SCM_DIRTY}" -eq 0 ]]; then + color=${SCM_THEME_PROMPT_CLEAN_COLOR} + fg_color=16 + else + color=${SCM_THEME_PROMPT_COLOR} + fg_color=255 + fi + # if [[ "${SCM_BRANCH}" == "master" ]]; then + # color=128 + # fg_color=251 + # fi + if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then + scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" + elif [[ "${SCM_P4_CHAR}" == "${SCM_CHAR}" ]]; then + scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" + elif [[ "${SCM_HG_CHAR}" == "${SCM_CHAR}" ]]; then + scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" + fi + echo "${scm_prompt}${scm}|${color}|${fg_color}" + fi +} + +function __powerline_cwd_prompt { + local cwd=$(pwd | sed "s|^${HOME}|~|") + local fg_color=16 + + echo "${cwd}|${CWD_THEME_PROMPT_COLOR}|${fg_color}" +} + +function __powerline_hostname_prompt { + local fg_color=206 + + echo "$(hostname -s)|${HOST_THEME_PROMPT_COLOR}|${fg_color}" +} + +function __powerline_wd_prompt { + local fg_color=206 + + echo "\W|${CWD_THEME_PROMPT_COLOR}|${fg_color}" +} + +function __powerline_clock_prompt { + local fg_color=206 + + echo "$(date +"${THEME_CLOCK_FORMAT}")|${CLOCK_THEME_PROMPT_COLOR}|${fg_color}" +} + +function __powerline_battery_prompt { + local color="" + local battery_status="$(battery_percentage 2> /dev/null)" + local fg_color=255 + + if [[ -z "${battery_status}" ]] || [[ "${battery_status}" = "-1" ]] || [[ "${battery_status}" = "no" ]]; then + true + else + if [[ "$((10#${battery_status}))" -le 5 ]]; then + color="${BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR}" + elif [[ "$((10#${battery_status}))" -le 25 ]]; then + color="${BATTERY_STATUS_THEME_PROMPT_LOW_COLOR}" + else + color="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}" + fi + ac_adapter_connected && battery_status="${BATTERY_AC_CHAR}${battery_status}" + echo "${battery_status}%|${color}|${fg_color}" + fi +} + +function __powerline_in_vim_prompt { + local fg_color=206 + + if [ -n "$VIMRUNTIME" ]; then + echo "${IN_VIM_THEME_PROMPT_TEXT}|${IN_VIM_THEME_PROMPT_COLOR}|${fg_color}" + fi +} + +function __powerline_aws_profile_prompt { + local fg_color=206 + + if [[ -n "${AWS_PROFILE}" ]]; then + echo "${AWS_PROFILE_CHAR}${AWS_PROFILE}|${AWS_PROFILE_PROMPT_COLOR}|${fg_color}" + fi +} + +function __powerline_left_segment { + local OLD_IFS="${IFS}"; IFS="|" + local params=( $1 ) + IFS="${OLD_IFS}" + local separator_char="${POWERLINE_LEFT_SEPARATOR}" + local separator="" + local fg_color=206 + + #for seperator character + if [[ "${SEGMENTS_AT_LEFT}" -gt 0 ]]; then + separator="$(set_color ${LAST_SEGMENT_COLOR} ${params[1]})${separator_char}${normal}" + fi + #change here to cahnge fg color + #echo "${params[0]} -> ${params[1]} -> ${params[2]}" + LEFT_PROMPT+="${separator}$(set_color ${params[2]} ${params[1]}) ${params[0]} ${normal}" + #seperator char color = current bg + LAST_SEGMENT_COLOR=${params[1]} + (( SEGMENTS_AT_LEFT += 1 )) +} + +function __powerline_last_status_prompt { + [[ "$1" -ne 0 ]] && echo "${1}|${LAST_STATUS_THEME_PROMPT_COLOR}" +} + +function __powerline_prompt_command { + local last_status="$?" ## always the first + local separator_char="${POWERLINE_PROMPT_CHAR}" + + LEFT_PROMPT="" + SEGMENTS_AT_LEFT=0 + LAST_SEGMENT_COLOR="" + + + if [[ -n "${POWERLINE_PROMPT_DISTRO_LOGO}" ]]; then + LEFT_PROMPT+="$(set_color ${PROMPT_DISTRO_LOGO_COLOR} ${PROMPT_DISTRO_LOGO_COLORBG})${PROMPT_DISTRO_LOGO}$(set_color - -)" + fi + + ## left prompt ## + for segment in $POWERLINE_PROMPT; do + local info="$(__powerline_${segment}_prompt)" + [[ -n "${info}" ]] && __powerline_left_segment "${info}" + done + + [[ "${last_status}" -ne 0 ]] && __powerline_left_segment $(__powerline_last_status_prompt ${last_status}) + [[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -)${separator_char}${normal}" + + PS1="${LEFT_PROMPT} " + + ## cleanup ## + unset LAST_SEGMENT_COLOR \ + LEFT_PROMPT \ + SEGMENTS_AT_LEFT +} + diff --git a/themes/gitline/redline.theme.bash b/themes/gitline/redline.theme.bash new file mode 100644 index 00000000..425c5897 --- /dev/null +++ b/themes/gitline/redline.theme.bash @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +. "$BASH_IT/themes/redline/powerline.base.bash" + +#For the logo +#PROMPT_DISTRO_LOGO="💻" +PROMPT_DISTRO_LOGO_COLOR=15 +PROMPT_DISTRO_LOGO_COLORBG=52 + +#Prompt Seperator Charactors +PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""} +POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""} + +#USER INFO CHARACTERS +USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "} +USER_INFO_SUDO_CHAR=${POWERLINE_USER_INFO_SUDO_CHAR:=" "} +USER_INFO_THEME_PROMPT_COLOR=91 +USER_INFO_THEME_PROMPT_COLOR_SUDO=1 + +PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:=" "} +CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="❲c❳ "} +PYTHON_VENV_THEME_PROMPT_COLOR=17 + +SCM_NONE_CHAR="" +SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "} +SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "} +SCM_THEME_PROMPT_CLEAN=" ✓ " +SCM_THEME_PROMPT_DIRTY=" ⨯ " +SCM_THEME_PROMPT_COLOR=91 +SCM_THEME_PROMPT_CLEAN_COLOR=41 +SCM_THEME_PROMPT_DIRTY_COLOR=94 +SCM_THEME_PROMPT_STAGED_COLOR=220 #52 +SCM_THEME_PROMPT_UNSTAGED_COLOR=81 +#SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} + + +RVM_THEME_PROMPT_PREFIX="" +RVM_THEME_PROMPT_SUFFIX="" +RBENV_THEME_PROMPT_PREFIX="" +RBENV_THEME_PROMPT_SUFFIX="" +RUBY_THEME_PROMPT_COLOR=161 +RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "} + +CWD_THEME_DIR_SEPARATOR="" +CWD_THEME_DIR_SEPARATOR_COLOR=52 +CWD_THEME_PROMPT_COLOR=252 + +HOST_THEME_PROMPT_COLOR=88 + +LAST_STATUS_THEME_PROMPT_COLOR=52 + +CLOCK_THEME_PROMPT_COLOR=240 + +BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="⚡"} +BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70 +BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208 +BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160 + +THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"} + +IN_VIM_THEME_PROMPT_COLOR=245 +IN_VIM_THEME_PROMPT_TEXT="vim" + +#POWERLINE_PROMPT=${POWERLINE_PROMPT:="python_venv ruby user_info hostname cwd scm"} +#POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"} + + +safe_append_prompt_command __powerline_prompt_command From fd1a477716f4ff6dc5a90be84f523c481286cef5 Mon Sep 17 00:00:00 2001 From: NEwa-05 Date: Fri, 11 Oct 2019 12:36:49 +0000 Subject: [PATCH 21/32] change git alias following issues #1419 --- aliases/available/git.aliases.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index fc95300d..7e3d53ee 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -27,7 +27,7 @@ alias gpr='git pull --rebase' alias gpp='git pull && git push' alias gup='git fetch && git rebase' alias gp='git push' -alias gpo='git push origin' +alias gpo='git push origin HEAD' alias gpu='git push --set-upstream' alias gpuo='git push --set-upstream origin' alias gpuoc='git push --set-upstream origin $(git symbolic-ref --short HEAD)' From 9a543ead482b0157cd7b774dcb1d7594c58e623c Mon Sep 17 00:00:00 2001 From: Zanark Date: Sat, 12 Oct 2019 13:15:24 +0530 Subject: [PATCH 22/32] renamed files --- themes/gitline/{redline.theme.bash => gitline.theme.bash} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename themes/gitline/{redline.theme.bash => gitline.theme.bash} (100%) diff --git a/themes/gitline/redline.theme.bash b/themes/gitline/gitline.theme.bash similarity index 100% rename from themes/gitline/redline.theme.bash rename to themes/gitline/gitline.theme.bash From 08785d96b574fa93f43a55c968edac697bbe33f3 Mon Sep 17 00:00:00 2001 From: Mattia Rigotti Date: Sat, 12 Oct 2019 11:48:51 +0200 Subject: [PATCH 23/32] Delete stand-alone theme sexy-python --- themes/sexy-python/sexy-python.theme.bash | 46 ----------------------- 1 file changed, 46 deletions(-) delete mode 100644 themes/sexy-python/sexy-python.theme.bash diff --git a/themes/sexy-python/sexy-python.theme.bash b/themes/sexy-python/sexy-python.theme.bash deleted file mode 100644 index e472218a..00000000 --- a/themes/sexy-python/sexy-python.theme.bash +++ /dev/null @@ -1,46 +0,0 @@ -# Small modification of Sexy Bash Prompt to include virtualenv and condaenv prompts -# (Sexy Bash Prompt is inspired by "Extravagant Zsh Prompt" -# with big thanks to \amethyst on Freenode) - -if tput setaf 1 &> /dev/null; then - if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then - MAGENTA=$(tput setaf 9) - ORANGE=$(tput setaf 172) - GREEN=$(tput setaf 190) - PURPLE=$(tput setaf 141) - WHITE=$(tput setaf 0) - else - MAGENTA=$(tput setaf 5) - ORANGE=$(tput setaf 4) - GREEN=$(tput setaf 2) - PURPLE=$(tput setaf 1) - WHITE=$(tput setaf 7) - fi - BOLD=$(tput bold) - RESET=$(tput sgr0) -else - MAGENTA="\033[1;31m" - ORANGE="\033[1;33m" - GREEN="\033[1;32m" - PURPLE="\033[1;35m" - WHITE="\033[1;37m" - BOLD="" - RESET="\033[m" -fi - -parse_git_dirty () { - [[ $(git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*" -} -parse_git_branch () { - git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" -} - -env_prompt () { - echo -e "($(virtualenv_prompt)$(condaenv_prompt))" -} - -function prompt_command() { - PS1="\[${BOLD}${WHITE}\]$(env_prompt) \[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]" -} - -safe_append_prompt_command prompt_command From a50a4ff633bed3ac27bd761f3e86889750696549 Mon Sep 17 00:00:00 2001 From: Mattia Rigotti Date: Sat, 12 Oct 2019 11:50:54 +0200 Subject: [PATCH 24/32] Rename variable to SEXY_THEME_SHOW_PYTHON --- themes/sexy/sexy.theme.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/sexy/sexy.theme.bash b/themes/sexy/sexy.theme.bash index 4250c540..fdbbf83d 100644 --- a/themes/sexy/sexy.theme.bash +++ b/themes/sexy/sexy.theme.bash @@ -4,7 +4,7 @@ # # Configuration: # * To visualize python environment (virtualenv and conda) add in your .bash_profile the following line: -# export SEXY_WITH_PYTHON=true +# export SEXY_THEME_SHOW_PYTHON=true if tput setaf 1 &> /dev/null; then if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then @@ -45,7 +45,7 @@ env_prompt () { function prompt_command() { PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]" - if [ "$SEXY_WITH_PYTHON" = true ] ; then + if [ "$SEXY_THEME_SHOW_PYTHON" = true ] ; then PS1="\[${BOLD}${WHITE}\]$(env_prompt) "$PS1 fi } From 05ded884658defde0fbc160a9d718f35f33bf845 Mon Sep 17 00:00:00 2001 From: Mattia Rigotti Date: Sat, 12 Oct 2019 11:52:53 +0200 Subject: [PATCH 25/32] Set SEXY_THEME_SHOW_PYTHON variable default value --- themes/sexy/sexy.theme.bash | 3 +++ 1 file changed, 3 insertions(+) diff --git a/themes/sexy/sexy.theme.bash b/themes/sexy/sexy.theme.bash index fdbbf83d..41d195d2 100644 --- a/themes/sexy/sexy.theme.bash +++ b/themes/sexy/sexy.theme.bash @@ -6,6 +6,9 @@ # * To visualize python environment (virtualenv and conda) add in your .bash_profile the following line: # export SEXY_THEME_SHOW_PYTHON=true +# Default setting +SEXY_THEME_SHOW_PYTHON="${SEXY_THEME_SHOW_PYTHON:=false}" + if tput setaf 1 &> /dev/null; then if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then MAGENTA=$(tput setaf 9) From 0e8b6775b9f3f0de09fea8049deb4318566a008e Mon Sep 17 00:00:00 2001 From: zwfang Date: Fri, 11 Oct 2019 23:09:50 +0800 Subject: [PATCH 26/32] Add a new theme named newin :) --- themes/newin/newin.theme.bash | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 themes/newin/newin.theme.bash diff --git a/themes/newin/newin.theme.bash b/themes/newin/newin.theme.bash new file mode 100644 index 00000000..9f54dc8a --- /dev/null +++ b/themes/newin/newin.theme.bash @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +SCM_THEME_PROMPT_DIRTY=" ${red}✗" +SCM_THEME_PROMPT_CLEAN=" ${green}✓" +SCM_THEME_PROMPT_PREFIX=" ${purple}|${green} " +SCM_THEME_PROMPT_SUFFIX="${purple} |" + +prompt() { + exit_code=$? + PS1="$(if [[ ${exit_code} = 0 ]]; then echo "${green}${exit_code}"; else echo "${red}${exit_code}"; fi) ${yellow}\t ${cyan}\w$(scm_prompt_info)${reset_color}\n${orange}$ ${reset_color}" +} + +safe_append_prompt_command prompt From f99ccbd1f20e2671821669458b5b704fecb3ed00 Mon Sep 17 00:00:00 2001 From: Zanark Date: Fri, 18 Oct 2019 11:13:19 +0530 Subject: [PATCH 27/32] Removed redundant code and added some descriptive comments --- themes/gitline/gitline.theme.bash | 12 ++++++------ themes/gitline/powerline.base.bash | 10 ++-------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/themes/gitline/gitline.theme.bash b/themes/gitline/gitline.theme.bash index 425c5897..3e6be360 100644 --- a/themes/gitline/gitline.theme.bash +++ b/themes/gitline/gitline.theme.bash @@ -2,7 +2,7 @@ . "$BASH_IT/themes/redline/powerline.base.bash" -#For the logo +#For the logo(Uncomment if you want a logo before your name) #PROMPT_DISTRO_LOGO="💻" PROMPT_DISTRO_LOGO_COLOR=15 PROMPT_DISTRO_LOGO_COLORBG=52 @@ -17,10 +17,12 @@ USER_INFO_SUDO_CHAR=${POWERLINE_USER_INFO_SUDO_CHAR:=" "} USER_INFO_THEME_PROMPT_COLOR=91 USER_INFO_THEME_PROMPT_COLOR_SUDO=1 +#PYTHON VENV PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:=" "} CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="❲c❳ "} PYTHON_VENV_THEME_PROMPT_COLOR=17 +#GIT Prompt Symbols SCM_NONE_CHAR="" SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "} SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "} @@ -31,9 +33,8 @@ SCM_THEME_PROMPT_CLEAN_COLOR=41 SCM_THEME_PROMPT_DIRTY_COLOR=94 SCM_THEME_PROMPT_STAGED_COLOR=220 #52 SCM_THEME_PROMPT_UNSTAGED_COLOR=81 -#SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} - +#Ruby Prompt Symbols RVM_THEME_PROMPT_PREFIX="" RVM_THEME_PROMPT_SUFFIX="" RBENV_THEME_PROMPT_PREFIX="" @@ -49,8 +50,10 @@ HOST_THEME_PROMPT_COLOR=88 LAST_STATUS_THEME_PROMPT_COLOR=52 +#Clock CLOCK_THEME_PROMPT_COLOR=240 +#For Battery Plugin BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="⚡"} BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70 BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208 @@ -61,8 +64,5 @@ THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"} IN_VIM_THEME_PROMPT_COLOR=245 IN_VIM_THEME_PROMPT_TEXT="vim" -#POWERLINE_PROMPT=${POWERLINE_PROMPT:="python_venv ruby user_info hostname cwd scm"} -#POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"} - safe_append_prompt_command __powerline_prompt_command diff --git a/themes/gitline/powerline.base.bash b/themes/gitline/powerline.base.bash index 925791fc..45387b02 100644 --- a/themes/gitline/powerline.base.bash +++ b/themes/gitline/powerline.base.bash @@ -1,4 +1,4 @@ -# Define this here so it can be used by all of the Powerline themes +# Sudo check after every command THEME_CHECK_SUDO=${THEME_CHECK_SUDO:=true} #To set color for foreground and background @@ -75,7 +75,7 @@ function __powerline_python_venv_prompt { [[ -n "${python_venv}" ]] && echo "${PYTHON_VENV_CHAR}${python_venv}|${PYTHON_VENV_THEME_PROMPT_COLOR}|${fg_color}" } -#Customising SCM Prompt +#Customising SCM(GIT) Prompt function __powerline_scm_prompt { local color="" local scm_prompt="" @@ -83,7 +83,6 @@ function __powerline_scm_prompt { scm_prompt_vars - # echo "${scm}" if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then if [[ "${SCM_DIRTY}" -eq 3 ]]; then @@ -102,10 +101,6 @@ function __powerline_scm_prompt { color=${SCM_THEME_PROMPT_COLOR} fg_color=255 fi - # if [[ "${SCM_BRANCH}" == "master" ]]; then - # color=128 - # fg_color=251 - # fi if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" elif [[ "${SCM_P4_CHAR}" == "${SCM_CHAR}" ]]; then @@ -191,7 +186,6 @@ function __powerline_left_segment { separator="$(set_color ${LAST_SEGMENT_COLOR} ${params[1]})${separator_char}${normal}" fi #change here to cahnge fg color - #echo "${params[0]} -> ${params[1]} -> ${params[2]}" LEFT_PROMPT+="${separator}$(set_color ${params[2]} ${params[1]}) ${params[0]} ${normal}" #seperator char color = current bg LAST_SEGMENT_COLOR=${params[1]} From cf86219418f3e62a916a15667dbdb677068188e5 Mon Sep 17 00:00:00 2001 From: wukuan405 Date: Mon, 28 Oct 2019 12:26:06 +0900 Subject: [PATCH 28/32] updated hub completion --- completion/available/hub.completion.bash | 36 ++++++++++++++++++------ 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/completion/available/hub.completion.bash b/completion/available/hub.completion.bash index bd84d322..8653084c 100644 --- a/completion/available/hub.completion.bash +++ b/completion/available/hub.completion.bash @@ -6,8 +6,8 @@ if ! declare -F _git > /dev/null && declare -F _completion_loader > /dev/null; t _completion_loader git fi -# Check that git tab completion is available -if declare -F _git > /dev/null; then +# Check that git tab completion is available and we haven't already set up completion +if declare -F _git > /dev/null && ! declare -F __git_list_all_commands_without_hub > /dev/null; then # Duplicate and rename the 'list_all_commands' function eval "$(declare -f __git_list_all_commands | \ sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')" @@ -17,11 +17,16 @@ if declare -F _git > /dev/null; then cat <<-EOF alias pull-request +pr +issue +release fork create +delete browse compare ci-status +sync EOF __git_list_all_commands_without_hub } @@ -213,21 +218,36 @@ EOF esac } - # hub fork [--no-remote] + # hub fork [--no-remote] [--remote-name REMOTE] [--org ORGANIZATION] _git_fork() { - local i c=2 remote=yes + local i c=2 flags="--no-remote --remote-name --org" while [ $c -lt $cword ]; do i="${words[c]}" case "$i" in + --org) + ((c++)) + flags=${flags/$i/} + ;; + --remote-name) + ((c++)) + flags=${flags/$i/} + flags=${flags/--no-remote/} + ;; --no-remote) - unset remote + flags=${flags/$i/} + flags=${flags/--remote-name/} ;; esac ((c++)) done - if [ -n "$remote" ]; then - __gitcomp "--no-remote" - fi + case "$prev" in + --remote-name|--org) + COMPREPLY=() + ;; + *) + __gitcomp "$flags" + ;; + esac } # hub pull-request [-f] [-m |-F |-i |] [-b ] [-h ] [-a ] [-M ] [-l ] From 35066f91b2c7472d06b822bb1de32752316c504c Mon Sep 17 00:00:00 2001 From: zwfang Date: Thu, 31 Oct 2019 21:56:54 +0800 Subject: [PATCH 29/32] add alias gcamd for `git commit --amend` --- aliases/available/git.aliases.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index 7e3d53ee..9a65b22a 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -43,6 +43,7 @@ alias gca='git commit -v -a' alias gcm='git commit -v -m' alias gcam="git commit -v -am" alias gci='git commit --interactive' +alias gcamd='git commit --amend' alias gb='git branch' alias gba='git branch -a' alias gbt='git branch --track' From f0c1caa090ecd3614c5c83a7554fe8c6144ab294 Mon Sep 17 00:00:00 2001 From: Zanark Date: Mon, 4 Nov 2019 15:19:52 +0530 Subject: [PATCH 30/32] resolved powerline.base path issue --- themes/gitline/gitline.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/gitline/gitline.theme.bash b/themes/gitline/gitline.theme.bash index 3e6be360..5debacb6 100644 --- a/themes/gitline/gitline.theme.bash +++ b/themes/gitline/gitline.theme.bash @@ -1,6 +1,6 @@ #!/usr/bin/env bash -. "$BASH_IT/themes/redline/powerline.base.bash" +. "$BASH_IT/themes/powerline/powerline.base.bash" #For the logo(Uncomment if you want a logo before your name) #PROMPT_DISTRO_LOGO="💻" From fcc3631a9a55cea9901d74b3725e26a39a2da532 Mon Sep 17 00:00:00 2001 From: Zanark Date: Mon, 4 Nov 2019 15:22:18 +0530 Subject: [PATCH 31/32] resolved powerline.base path issue --- themes/gitline/gitline.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/gitline/gitline.theme.bash b/themes/gitline/gitline.theme.bash index 5debacb6..995b8c07 100644 --- a/themes/gitline/gitline.theme.bash +++ b/themes/gitline/gitline.theme.bash @@ -1,6 +1,6 @@ #!/usr/bin/env bash -. "$BASH_IT/themes/powerline/powerline.base.bash" +. "$BASH_IT/themes/gitline/powerline.base.bash" #For the logo(Uncomment if you want a logo before your name) #PROMPT_DISTRO_LOGO="💻" From 377f02714def7c259cdc8a24d4c08622b1c929dd Mon Sep 17 00:00:00 2001 From: cornfeedhobo Date: Wed, 20 Nov 2019 01:49:34 -0600 Subject: [PATCH 32/32] Simplify multiple path support in go plugin (#1284) * simplify wrapped pathmunge logic. update tests to account for cases with spaces in $PATH. --- plugins/available/go.plugin.bash | 24 ++++-------- test/plugins/go.plugin.bats | 65 ++++++++++++++++++-------------- 2 files changed, 44 insertions(+), 45 deletions(-) diff --git a/plugins/available/go.plugin.bash b/plugins/available/go.plugin.bash index 910194e5..566d7669 100755 --- a/plugins/available/go.plugin.bash +++ b/plugins/available/go.plugin.bash @@ -3,27 +3,17 @@ cite about-plugin about-plugin 'go environment variables & path configuration' -[ ! command -v go &>/dev/null ] && return +command -v go &>/dev/null || return -function _split_path_reverse() { - local a=( ${@//:/ } ) +function _go_pathmunge_wrap() { + IFS=':' local -a 'a=($1)' local i=${#a[@]} - local r= while [ $i -gt 0 ] ; do i=$(( i - 1 )) - if [ $(( i + 1 )) -eq ${#a[@]} ] ; then - r="${a[i]}" - else - r="${r} ${a[i]}" - fi + pathmunge "${a[i]}/bin" done - echo "$r" } -export GOROOT=${GOROOT:-$(go env GOROOT)} -pathmunge "${GOROOT}/bin" - -export GOPATH=${GOPATH:-$(go env GOPATH)} -for p in $( _split_path_reverse ${GOPATH} ) ; do - pathmunge "${p}/bin" -done +export GOROOT="${GOROOT:-$(go env GOROOT)}" +export GOPATH="${GOPATH:-$(go env GOPATH)}" +_go_pathmunge_wrap "${GOPATH}:${GOROOT}" diff --git a/test/plugins/go.plugin.bats b/test/plugins/go.plugin.bats index e2b27e02..02806205 100644 --- a/test/plugins/go.plugin.bats +++ b/test/plugins/go.plugin.bats @@ -1,44 +1,53 @@ #!/usr/bin/env bats -#load ../test_helper +load ../test_helper load ../../lib/helpers load ../../lib/composure -load ../../plugins/available/go.plugin -@test 'plugins go: reverse path: single entry' { - run _split_path_reverse '/foo' - echo "output = ${output}" - [ "$output" = "/foo" ] -} - -@test 'plugins go: reverse path: single entry, colon empty' { - run _split_path_reverse '/foo:' - echo "output = ${output}" - [ "$output" = "/foo" ] -} - -@test 'plugins go: reverse path: single entry, colon whitespace' { - run _split_path_reverse '/foo: ' - echo "output = ${output}" - [ "$output" = "/foo" ] -} - -@test 'plugins go: reverse path: multiple entries' { - run _split_path_reverse '/foo:/bar' - echo "output = ${output}" - [ "$output" = "/bar /foo" ] +@test 'ensure _go_pathmunge_wrap is defined' { + load ../../plugins/available/go.plugin + run type -t _go_pathmunge_wrap + assert_line 'function' } @test 'plugins go: single entry in GOPATH' { export GOPATH="/foo" + export GOROOT="/baz" load ../../plugins/available/go.plugin - echo "$(echo $PATH | cut -d':' -f1,2)" - [ "$(echo $PATH | cut -d':' -f1)" = "/foo/bin" ] + assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo/bin:/baz/bin" +} + +@test 'plugins go: single entry in GOPATH, with space' { + export GOPATH="/foo bar" + export GOROOT="/baz" + load ../../plugins/available/go.plugin + assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo bar/bin:/baz/bin" +} + +@test 'plugins go: single entry in GOPATH, with escaped space' { + export GOPATH="/foo\ bar" + export GOROOT="/baz" + load ../../plugins/available/go.plugin + assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo\ bar/bin:/baz/bin" } @test 'plugins go: multiple entries in GOPATH' { export GOPATH="/foo:/bar" + export GOROOT="/baz" load ../../plugins/available/go.plugin - echo "$(echo $PATH | cut -d':' -f1,2)" - [ "$(echo $PATH | cut -d':' -f1,2)" = "/foo/bin:/bar/bin" ] + assert_equal "$(cut -d':' -f1,2,3 <<<$PATH)" "/foo/bin:/bar/bin:/baz/bin" +} + +@test 'plugins go: multiple entries in GOPATH, with space' { + export GOPATH="/foo:/foo bar" + export GOROOT="/baz" + load ../../plugins/available/go.plugin + assert_equal "$(cut -d':' -f1,2,3 <<<$PATH)" "/foo/bin:/foo bar/bin:/baz/bin" +} + +@test 'plugins go: multiple entries in GOPATH, with escaped space' { + export GOPATH="/foo:/foo\ bar" + export GOROOT="/baz" + load ../../plugins/available/go.plugin + assert_equal "$(cut -d':' -f1,2,3 <<<$PATH)" "/foo/bin:/foo\ bar/bin:/baz/bin" }