diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index c311c99ba0..f56675e66d 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -3,6 +3,7 @@ about-alias 'common git abbreviations' alias g='git' alias get='git' +alias got='git ' # add alias ga='git add' @@ -32,6 +33,9 @@ alias gca='git commit -v -a' alias gcaa='git commit -a --amend -C HEAD' # Add uncommitted and unstaged changes to the last commit alias gcam='git commit -v -am' alias gcamd='git commit --amend' +alias gc!='git commit -v --amend' +alias gca!='git commit -v -a --amend' +alias gcn!='git commit -v --amend --no-edit' alias gcm='git commit -v -m' alias gci='git commit --interactive' alias gcsam='git commit -S -am' @@ -79,6 +83,8 @@ alias ggup='git log --branches --not --remotes --no-walk --decorate --oneline' # alias gll='git log --graph --pretty=oneline --abbrev-commit' alias gnew='git log HEAD@{1}..HEAD@{0}' # Show commits since last pull, see http://blogs.atlassian.com/2014/10/advanced-git-aliases/ alias gwc='git whatchanged' +alias ghist='git log --pretty=format:'\''%h %ad | %s%d [%an]'\'' --graph --date=short' # Use it to be fast and without color. +alias gprogress='git log --pretty=format:'\''%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d'\'' --decorate --date=short' #Usually use "git progress" in the file .gitconfig. The new alias from Git friends will be truly welcome. # ls-files alias gu='git ls-files . --exclude-standard --others' # Show untracked files @@ -110,7 +116,8 @@ alias gpatch='git format-patch -1' # push alias gp='git push' alias gpd='git push --delete' -alias gpf='git push --force' +alias gpf='git push --force-with-lease' +alias gpff='git push --force' alias gpo='git push origin HEAD' alias gpom='git push origin $(get_default_branch)' alias gpu='git push --set-upstream' @@ -120,6 +127,7 @@ alias gpuoc='git push --set-upstream origin $(git symbolic-ref --short HEAD)' # pull alias gl='git pull' +alias glp='git pull --prune' alias glum='git pull upstream $(get_default_branch)' alias gpl='git pull' alias gpp='git pull && git push' @@ -132,6 +140,7 @@ alias grv='git remote -v' # rm alias grm='git rm' +alias grmc='git rm --cached' # Removes the file only from the Git repository, but not from the filesystem. This is useful to undo some of the changes you made to a file before you commit it. # rebase alias grb='git rebase' @@ -144,7 +153,9 @@ alias grma='GIT_SEQUENCE_EDITOR=: git rebase $(get_default_branch) -i --autosqu alias gprom='git fetch origin $(get_default_branch) && git rebase origin/$(get_default_branch) && git update-ref refs/heads/$(get_default_branch) origin/$(get_default_branch)' # Rebase with latest remote # reset -alias gus='git reset HEAD' +alias gus='git reset HEAD' # read as: 'git unstage' +alias grh='git reset' # equivalent to: git reset HEAD +alias grh!='git reset --hard' alias gpristine='git reset --hard && git clean -dfx' # status @@ -211,9 +222,6 @@ function gdv() { } function get_default_branch() { - if git branch | grep -q '^. main\s*$'; then - echo main - else - echo master - fi + branch=$(git symbolic-ref refs/remotes/origin/HEAD) + ${branch#refs/remotes/origin/} } diff --git a/aliases/available/maven.aliases.bash b/aliases/available/maven.aliases.bash index 737826eb47..2746da2c95 100644 --- a/aliases/available/maven.aliases.bash +++ b/aliases/available/maven.aliases.bash @@ -3,8 +3,13 @@ about-alias 'maven abbreviations' alias mci='mvn clean install' alias mi='mvn install' -alias mcp='mvn clean package' +alias mc='mvn clean' +alias mct='mvn clean test' +alias mcc='mvn clean compile' +alias mccnt='mvn clean compile -DskipTests=true' alias mp='mvn package' +alias mcp='mvn clean package' +alias mcpnt='mvn clean package -DskipTests=true' alias mrprep='mvn release:prepare' alias mrperf='mvn release:perform' alias mrrb='mvn release:rollback' @@ -12,3 +17,9 @@ alias mdep='mvn dependency:tree' alias mpom='mvn help:effective-pom' alias mcisk='mci -Dmaven.test.skip=true' alias mcpsk='mcp -Dmaven.test.skip=true' + +# Maven service plugin aliases +alias mspring='mvn spring-boot:run' +alias mjetty='mvn jetty:run' +alias mquark='mvn quarkus:dev' +alias mmicro='mvn mn:run' diff --git a/clean_files.txt b/clean_files.txt index 7cc722cf28..e8dff795bf 100644 --- a/clean_files.txt +++ b/clean_files.txt @@ -19,6 +19,7 @@ aliases/ docs/ hooks/ +lib/ scripts/ test/ @@ -32,6 +33,7 @@ lint_clean_files.sh # completions # +completion/available/aliases.completion.bash completion/available/apm.completion.bash completion/available/awless.completion.bash completion/available/awscli.completion.bash @@ -47,6 +49,7 @@ completion/available/dmidecode.completion.bash completion/available/docker-machine.completion.bash completion/available/docker.completion.bash completion/available/dotnet.completion.bash +completion/available/export.completion.bash completion/available/flutter.completion.bash completion/available/gcloud.completion.bash completion/available/gem.completion.bash @@ -79,18 +82,6 @@ completion/available/vuejs.completion.bash completion/available/wpscan.completion.bash completion/available/yarn.completion.bash -# libraries -lib/appearance.bash -lib/colors.bash -lib/command_duration.bash -lib/helpers.bash -lib/history.bash -lib/log.bash -lib/preexec.bash -lib/preview.bash -lib/search.bash -lib/utilities.bash - # plugins # plugins/available/alias-completion.plugin.bash @@ -135,6 +126,7 @@ plugins/available/rbenv.plugin.bash plugins/available/ruby.plugin.bash plugins/available/textmate.plugin.bash plugins/available/todo.plugin.bash +plugins/available/url.plugin.bash plugins/available/xterm.plugin.bash plugins/available/zoxide.plugin.bash @@ -160,9 +152,13 @@ themes/bobby-python themes/brainy themes/brunton themes/candy +themes/clean themes/easy +themes/elixr themes/essential themes/githelpers.theme.bash +themes/inretio +themes/lambda themes/modern themes/norbu themes/oh-my-posh @@ -172,6 +168,7 @@ themes/powerline themes/pure themes/purity + # vendor init files # vendor/.gitattributes diff --git a/completion/available/aliases.completion.bash b/completion/available/aliases.completion.bash index 3e45e960cf..a4b15959a8 100644 --- a/completion/available/aliases.completion.bash +++ b/completion/available/aliases.completion.bash @@ -20,7 +20,7 @@ function _bash-it-component-completion-callback-on-init-aliases() { completions=("${completions[@]##complete -* * -}") # strip all but last option plus trigger(s) completions=("${completions[@]#complete -}") # strip anything missed completions=("${completions[@]#? * }") # strip last option and arg, leaving only trigger(s) - completions=("${completions[@]#? }") # strip anything missed + completions=("${completions[@]#? }") # strip anything missed #TODO: this will fail on some completions... # create temporary file for wrapper functions and completions @@ -40,10 +40,10 @@ function _bash-it-component-completion-callback-on-init-aliases() { line="${line#alias -- }" line="${line#alias }" alias_name="${line%%=*}" - alias_defn="${line#*=\'}" # alias definition + alias_defn="${line#*=\'}" # alias definition alias_defn="${alias_defn%\'}" alias_cmd="${alias_defn%%[[:space:]]*}" # first word of alias - if [[ ${alias_defn} == ${alias_cmd} ]]; then + if [[ ${alias_defn} == "${alias_cmd}" ]]; then alias_args='' else alias_args="${alias_defn#*[[:space:]]}" # everything after first word @@ -89,7 +89,7 @@ function _bash-it-component-completion-callback-on-init-aliases() { prec_word=\${prec_word#* } fi (( COMP_CWORD += ${#alias_arg_words[@]} )) - COMP_WORDS=(\"$alias_cmd\" \"${alias_arg_words[@]}\" \"\${COMP_WORDS[@]:1}\") + COMP_WORDS=(\"$alias_cmd\" \"${alias_arg_words[*]}\" \"\${COMP_WORDS[@]:1}\") (( COMP_POINT -= \${#COMP_LINE} )) COMP_LINE=\${COMP_LINE/$alias_name/$alias_cmd $alias_args} (( COMP_POINT += \${#COMP_LINE} )) diff --git a/completion/available/export.completion.bash b/completion/available/export.completion.bash index 42da3a97be..4898eb9a01 100644 --- a/completion/available/export.completion.bash +++ b/completion/available/export.completion.bash @@ -1 +1,3 @@ -complete -o nospace -S = -W '$(printenv | awk -F= "{print \$1}")' export +# shellcheck shell=bash + +complete -o nospace -S = -W "$(printenv | awk -F= "{print \$1}")" export diff --git a/docs/themes-list/index.rst b/docs/themes-list/index.rst index 0275001b38..0196ba62ed 100644 --- a/docs/themes-list/index.rst +++ b/docs/themes-list/index.rst @@ -221,6 +221,21 @@ Envy ---- +Inretio +^^^^^^^ + + +.. image:: https://raw.githubusercontent.com/inretio/bash-it/gh-pages/docs/images/inretio-black.png + :target: https://raw.githubusercontent.com/inretio/bash-it/gh-pages/docs/images/inretio-black.png + :alt: Inretio theme in dark color scheme + + +.. image:: https://raw.githubusercontent.com/inretio/bash-it/gh-pages/docs/images/inretio-white.png + :target: https://raw.githubusercontent.com/inretio/bash-it/gh-pages/docs/images/inretio-white.png + :alt: Inretio theme in light color scheme + +---- + Iterate ^^^^^^^ diff --git a/docs/themes-list/inretio.rst b/docs/themes-list/inretio.rst new file mode 100644 index 0000000000..0e424a99f8 --- /dev/null +++ b/docs/themes-list/inretio.rst @@ -0,0 +1,32 @@ +.. _inretio: + +Inretio Theme +============= + +Simple theme showing date and time, username and hostname, current folder, Git details and as a bonus - virtual environment along with Python version available in it. + +Inspired by existing themes: +- metal +- bobby + +Examples +-------- + +In Git-tracked folder: + +.. code-block:: bash + + ā”Œā”€ā”€[2024-03-20 12:05:07] šŸ§ gytis šŸ’» gytis-legion šŸ“‚ bash-it on šŸŒµ theme-inretio āŒ€1 āœ— + ā””> ls + aliases clean_files.txt custom hooks lib lint_clean_files.sh profiles template test_lib uninstall.sh + bash_it.sh completion docs install.sh LICENSE plugins scripts test themes vendor + + +In Python virtual environment: + +.. code-block:: bash + + ā”Œā”€ā”€[2024-03-20 12:07:32] šŸ§ gytis šŸ’» gytis-legion šŸ 3.12.2 on [general] šŸ“‚ general + ā””> ls + bin include lib lib64 pyvenv.cfg share + diff --git a/docs/themes-list/powerline-base.rst b/docs/themes-list/powerline-base.rst index faa1af3401..f38f940daa 100644 --- a/docs/themes-list/powerline-base.rst +++ b/docs/themes-list/powerline-base.rst @@ -81,7 +81,7 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o * ``python_venv`` - Python virtual environment information (\ ``virtualenv``\ , ``venv`` and ``conda`` supported) * ``ruby`` - Current ruby version if using ``rvm`` -* ``node`` - Current node version (only ``nvm`` is supported) +* ``node`` - Current node version (``nvm`` is the default strategy; set ``NODE_VERSION_STRATEGY`` to ``node`` to use ``node --version``) * ``scm`` - Version control information, ``git`` * ``terraform`` - Current terraform workspace * ``user_info`` - Current user diff --git a/lib/command_duration.bash b/lib/command_duration.bash index 2b5e1b4bda..352ef0f01a 100644 --- a/lib/command_duration.bash +++ b/lib/command_duration.bash @@ -26,7 +26,7 @@ function _dynamic_clock_icon { local clock_hand # clock hand value is between 90 and 9b in hexadecimal. # so between 144 and 155 in base 10. - printf -v clock_hand '%x' $(((${1:-${SECONDS}} % 12) + 144)) + printf -v clock_hand '%x' $((((${1:-${SECONDS}} - 1) % 12) + 144)) printf -v 'COMMAND_DURATION_ICON' '%b' "\xf0\x9f\x95\x$clock_hand" } diff --git a/lint_clean_files.sh b/lint_clean_files.sh index cc2686042f..b341f4f46f 100755 --- a/lint_clean_files.sh +++ b/lint_clean_files.sh @@ -10,7 +10,7 @@ mapfile -t FILES < <( cat clean_files.txt \ | grep -E -v '^\s*$' \ | grep -E -v '^\s*#' \ - | xargs -n1 -I{} find "{}" -type f + | xargs -I{} find "{}" -type f ) # We clear the BASH_IT variable to help the shellcheck checker diff --git a/plugins/available/gif.plugin.bash b/plugins/available/gif.plugin.bash index 1f47f1f013..7cca37d4d2 100644 --- a/plugins/available/gif.plugin.bash +++ b/plugins/available/gif.plugin.bash @@ -64,7 +64,7 @@ function v2gif() { fi # Parse the options - args=$("$getopt" -l "alert:" -l "lossy:" -l "width:" -l del,delete -l high -l tag -l "fps:" -l webm -o "a:l:w:f:dhmt" -- "$@") || { + args=$("$getopt" -l "alert:" -l "lossy:" -l "width:" -l del,delete -l high -l help -l tag -l "fps:" -l webm -o "a:l:w:f:dhmt" -- "$@") || { echo 'Terminating...' >&2 return 2 } @@ -82,6 +82,7 @@ function v2gif() { local fps="" local make_webm="" local alert=5000 + local printhelp="" while [[ $# -ge 1 ]]; do case "$1" in --) @@ -94,6 +95,11 @@ function v2gif() { opt_del_after="true" shift ;; + --help) + # Print Help + printhelp="true" + shift + ;; -h | --high) #High Quality, use gifski gifski="$(type -p gifski)" @@ -141,7 +147,7 @@ function v2gif() { esac done - if [[ -z "$*" ]]; then + if [[ -z "$*" || "$printhelp" ]]; then echo "$(tput setaf 1)No input files given. Example: v2gif file [file...] [-w ] [-l ] $(tput sgr 0)" echo "-d/--del/--delete Delete original vid if done suceessfully (and file not over the size limit)" echo "-h/--high High Quality - use Gifski instead of gifsicle" diff --git a/plugins/available/nvm.plugin.bash b/plugins/available/nvm.plugin.bash index 0e6da5d8cf..4dc4c6d630 100644 --- a/plugins/available/nvm.plugin.bash +++ b/plugins/available/nvm.plugin.bash @@ -9,10 +9,18 @@ cite about-plugin about-plugin 'node version manager configuration' export NVM_DIR="${NVM_DIR:-$HOME/.nvm}" + +# first check if NVM is managed by brew +NVM_BREW_PREFIX="" +if _bash_it_homebrew_check +then + NVM_BREW_PREFIX=$(brew --prefix nvm 2>/dev/null) +fi + # This loads nvm -if _bash_it_homebrew_check && [[ -s "${BASH_IT_HOMEBREW_PREFIX}/nvm.sh" ]] +if [[ -n "$NVM_BREW_PREFIX" && -s "${NVM_BREW_PREFIX}/nvm.sh" ]] then - source "${BASH_IT_HOMEBREW_PREFIX}/nvm.sh" + source "${NVM_BREW_PREFIX}/nvm.sh" else [[ -s "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh" fi diff --git a/plugins/available/url.plugin.bash b/plugins/available/url.plugin.bash new file mode 100644 index 0000000000..72a41bfd3a --- /dev/null +++ b/plugins/available/url.plugin.bash @@ -0,0 +1,45 @@ +# shellcheck shell=bash +cite about-plugin +about-plugin 'Basic url handling and manipulation functions' + +function slugify() { + about 'takes the text and transform to slug url, also supports formats like (html,link,rst,md)' + group 'url' + param "1: Text to transform (optional)" + param "2: Output format (html,rst,link,md). Omit or pass any text to return only output" + + local TXT=$1 + local OUTPUT=$2 + local SLUG + + if [[ -z $TXT ]]; then + read -rp "Enter the valid string: " TXT + fi + + # Pass 1 - Clean the url + # Credits: https://stackoverflow.com/a/20007549/10362396 + SLUG=$(echo -n "$TXT" | tr -cd ' [:alnum:]._-' | tr -s ' ') + + # Pass 2 - Transformation + SLUG=$(echo -n "$SLUG" | tr '[:upper:]' '[:lower:]' | tr ' ' '-') + + case "$OUTPUT" in + html | htm) + echo "$TXT" + ;; + href | link) + echo "#$SLUG" + ;; + md) + echo "[$TXT](#$SLUG)" + ;; + rst) + echo "\`$TXT <#$SLUG>\`_" + ;; + + *) + echo "$SLUG" + ;; + esac + +} diff --git a/test/test_helper.bash b/test/test_helper.bash index 9728801681..58daeeef19 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -41,7 +41,7 @@ function common_setup_file() { BASH_IT="${BATS_FILE_TMPDIR//\/\///}/.bash_it" # This sets up a local test fixture, i.e. a completely fresh and isolated Bash-it directory. This is done to avoid messing with your own Bash-it source directory. - git --git-dir="${MAIN_BASH_IT_GITDIR?}" worktree add -d "${BASH_IT}" + git --git-dir="${MAIN_BASH_IT_GITDIR?}" worktree add --detach "${BASH_IT}" load "${BASH_IT?}/vendor/github.com/erichs/composure/composure.sh" # support 'plumbing' metadata diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 92a56e5ec0..e25014f86b 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -74,6 +74,9 @@ SCM_NONE_CHAR='ā—‹' NVM_THEME_PROMPT_PREFIX=' |' NVM_THEME_PROMPT_SUFFIX='|' +NODE_THEME_PROMPT_PREFIX=' |' +NODE_THEME_PROMPT_SUFFIX='|' + RVM_THEME_PROMPT_PREFIX=' |' RVM_THEME_PROMPT_SUFFIX='|' @@ -399,8 +402,24 @@ function nvm_version_prompt() { fi } +function node_native_version_prompt() { + local node + if _command_exists node; then + node=$(node --version 2> /dev/null) + echo -ne "${NODE_THEME_PROMPT_PREFIX-}${node}${NODE_THEME_PROMPT_SUFFIX-}" + fi +} + function node_version_prompt() { - nvm_version_prompt + NODE_VERSION_STRATEGY="${NODE_VERSION_STRATEGY:-nvm}" + + _log_debug "node: using version strategy '$NODE_VERSION_STRATEGY'" + + if [ "$NODE_VERSION_STRATEGY" == "nvm" ]; then + nvm_version_prompt + elif [ "$NODE_VERSION_STRATEGY" == "node" ]; then + node_native_version_prompt + fi } function rvm_version_prompt() { diff --git a/themes/bira/bira.theme.bash b/themes/bira/bira.theme.bash index f30d8d5d00..cba4e425b8 100644 --- a/themes/bira/bira.theme.bash +++ b/themes/bira/bira.theme.bash @@ -6,6 +6,8 @@ SCM_THEME_PROMPT_SUFFIX="ā€ŗ${reset_color?}" VIRTUALENV_THEME_PROMPT_PREFIX=" ${cyan?}ā€¹" VIRTUALENV_THEME_PROMPT_SUFFIX="ā€ŗ${reset_color?}" +CONDAENV_THEME_PROMPT_PREFIX=" ${cyan?}ā€¹" +CONDAENV_THEME_PROMPT_SUFFIX="ā€ŗ${reset_color?}" bold="\[\e[1m\]" @@ -18,7 +20,7 @@ fi function prompt_command() { local current_dir=" ${bold_blue?}\w${normal?}${reset_color?}" local virtualenv_prompt scm_prompt_info - virtualenv_prompt="$(virtualenv_prompt)" + virtualenv_prompt="${virtualenv_prompt:-$(condaenv_prompt)}" scm_prompt_info="$(scm_prompt_info)" PS1="ā•­ā”€${user_host?}${current_dir}${virtualenv_prompt}${scm_prompt_info}\nā•°ā”€${bold?}\\$ ${normal?}" } diff --git a/themes/clean/clean.theme.bash b/themes/clean/clean.theme.bash index 0082d671a0..47a436b34d 100644 --- a/themes/clean/clean.theme.bash +++ b/themes/clean/clean.theme.bash @@ -1,19 +1,24 @@ +# shellcheck shell=bash +# shellcheck disable=SC2034 # Expected behavior for themes. + # git theming -SCM_THEME_PROMPT_PREFIX="${bold_blue}(${yellow}" -SCM_THEME_PROMPT_SUFFIX="${bold_blue})${reset_color} " +SCM_THEME_PROMPT_PREFIX="${bold_blue?}(${yellow?}" +SCM_THEME_PROMPT_SUFFIX="${bold_blue?})${reset_color?} " SCM_THEME_PROMPT_CLEAN="" -SCM_THEME_PROMPT_DIRTY="${bold_red}āœ—" - +SCM_THEME_PROMPT_DIRTY="${bold_red?}āœ—" # LS colors, made with http://geoff.greer.fm/lscolors/ export LSCOLORS="Gxfxcxdxbxegedabagacad" export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:' function prompt_command() { + if [ "$(whoami)" = root ]; then + no_color=${red?} + else + no_color=${white?} + fi - 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 diff --git a/themes/elixr/elixr.theme.bash b/themes/elixr/elixr.theme.bash index 266abbad43..d266fae89d 100644 --- a/themes/elixr/elixr.theme.bash +++ b/themes/elixr/elixr.theme.bash @@ -1,15 +1,16 @@ -#!/usr/bin/env bash +# shellcheck shell=bash +# shellcheck disable=SC2034 # Expected behavior for themes. -SCM_THEME_PROMPT_DIRTY=" ${red}āœ—" -SCM_THEME_PROMPT_CLEAN=" ${bold_green}āœ“" -SCM_THEME_PROMPT_PREFIX=" ${green}| " -SCM_THEME_PROMPT_SUFFIX="${green} |" +SCM_THEME_PROMPT_DIRTY=" ${red?}āœ—" +SCM_THEME_PROMPT_CLEAN=" ${bold_green?}āœ“" +SCM_THEME_PROMPT_PREFIX=" ${green?}| " +SCM_THEME_PROMPT_SUFFIX="${green?} |" SCM_NONE_CHAR='ā— ' SCM_GIT_SHOW_MINIMAL_INFO=true -GIT_THEME_PROMPT_DIRTY=" ${red}āœ—" -GIT_THEME_PROMPT_CLEAN=" ${bold_green}āœ“" -GIT_THEME_PROMPT_PREFIX=" ${green}|" -GIT_THEME_PROMPT_SUFFIX="${green}|" +GIT_THEME_PROMPT_DIRTY=" ${red?}āœ—" +GIT_THEME_PROMPT_CLEAN=" ${bold_green?}āœ“" +GIT_THEME_PROMPT_PREFIX=" ${green?}|" +GIT_THEME_PROMPT_SUFFIX="${green?}|" RVM_THEME_PROMPT_PREFIX="|" RVM_THEME_PROMPT_SUFFIX=" d|" @@ -17,7 +18,7 @@ RVM_THEME_PROMPT_SUFFIX=" d|" BOLD="\[\e[1m\]" function prompt_command() { - PS1="\n${bold_cyan}$(scm_prompt_char_info)$(virtualenv_prompt) ${bold_cyan}\w :${reset_color}${normal}${BOLD} " + PS1="\n${bold_cyan?}$(scm_prompt_char_info)$(virtualenv_prompt) ${bold_cyan}\w :${reset_color?}${normal?}${BOLD} " } safe_append_prompt_command prompt_command diff --git a/themes/inretio/inretio.theme.bash b/themes/inretio/inretio.theme.bash new file mode 100644 index 0000000000..58ac36ddfb --- /dev/null +++ b/themes/inretio/inretio.theme.bash @@ -0,0 +1,100 @@ +# shellcheck shell=bash +# shellcheck disable=SC2034 # Expected behavior for themes. + +# Inretio theme for Bash-it +# Contact: bashit@inretio.eu + +# Inspired by existing themes: +# - metal +# - bobby + +# virtualenv prompts +VIRTUALENV_CHAR=" ā“”" +VIRTUALENV_THEME_PROMPT_PREFIX="" +VIRTUALENV_THEME_PROMPT_SUFFIX="" + +# SCM prompts +SCM_NONE_CHAR="" +SCM_GIT_CHAR="[Ā±] " +SCM_GIT_BEHIND_CHAR="${red}ā†“${normal}" +SCM_GIT_AHEAD_CHAR="${bold_green}ā†‘${normal}" +SCM_GIT_UNTRACKED_CHAR="āŒ€" +SCM_GIT_UNSTAGED_CHAR="${bold_yellow}ā€¢${normal}" +SCM_GIT_STAGED_CHAR="${bold_green}+${normal}" + +SCM_THEME_PROMPT_DIRTY="" +SCM_THEME_PROMPT_CLEAN="" +SCM_THEME_PROMPT_PREFIX="" +SCM_THEME_PROMPT_SUFFIX="" + +# Git status prompts +GIT_THEME_PROMPT_DIRTY=" ${red}āœ—${normal}" +GIT_THEME_PROMPT_CLEAN=" ${bold_green}āœ“${normal}" +GIT_THEME_PROMPT_PREFIX="" +GIT_THEME_PROMPT_SUFFIX="" + +# ICONS ======================================================================= + +icon_start="ā”Œā”€ā”€" +icon_user=" šŸ§ " +icon_host=" šŸ’» " +icon_directory=" šŸ“‚ " +icon_branch="šŸŒµ" +icon_end="ā””> " + +# extra spaces ensure legiblity in prompt + +# FUNCTIONS =================================================================== + +# Display virtual environment info +function _virtualenv_prompt { + VIRTUALENV_DETAILS="" + VIRTUALENV_CHAR="" + + # $VIRTUAL_ENV is set and is non-zero length + if [[ -n "$VIRTUAL_ENV" ]]; then + # Check if Python 3 exists + if command -v python3 >/dev/null 2>&1; then + VIRTUALENV_DETAILS="$($VIRTUAL_ENV/bin/python --version | sed 's,Python ,,') on [$(basename $VIRTUAL_ENV)]" + VIRTUALENV_CHAR=" šŸ" + else + VIRTUALENV_DETAILS="[$(basename $VIRTUAL_ENV)]" + VIRTUALENV_CHAR=" ā“”" + fi + fi + + echo "$VIRTUALENV_CHAR $VIRTUALENV_DETAILS" +} + +# Rename tab +function tabname { + printf "\e]1;$1\a" +} + +# Rename window +function winname { + printf "\e]2;$1\a" +} + +_theme_clock() { + printf '[%s]' "$(clock_prompt)" + + if [ "${THEME_SHOW_CLOCK_CHAR}" == "true" ]; then + printf '%s' "$(clock_char) " + fi +} +THEME_SHOW_CLOCK_CHAR=${THEME_SHOW_CLOCK_CHAR:-"false"} +THEME_CLOCK_CHAR_COLOR=${THEME_CLOCK_CHAR_COLOR:-"$red"} +THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$normal"} +THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%Y-%m-%d %H:%M:%S"} + +# PROMPT OUTPUT =============================================================== + +# Displays the current prompt +function prompt_command() { + PS1="\n${icon_start}$(_theme_clock)${icon_user}${bold_green}\u${normal}${icon_host}${bold_cyan}\h${normal}${green}$(_virtualenv_prompt)${normal}${icon_directory}${bold_purple}\W${normal}\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on ${icon_branch} $(scm_prompt_info) \")${white}${normal}\n${icon_end}" + PS2="${icon_end}" +} + +# Runs prompt (this bypasses bash_it $PROMPT setting) +safe_append_prompt_command prompt_command diff --git a/themes/lambda/lambda.theme.bash b/themes/lambda/lambda.theme.bash new file mode 100644 index 0000000000..8f3d5baf49 --- /dev/null +++ b/themes/lambda/lambda.theme.bash @@ -0,0 +1,33 @@ +#!/bin/bash +# shellcheck disable=SC1090,SC2034 + +function set_prompt { + local user_color="\[\033[1;31m\]" # bold red for username + local at_color="\[\033[1;37m\]" # bold white for @ symbol + local host_color="\[\033[1;31m\]" # bold red for hostname + local in_color="\[\033[1;37m\]" # bold white for "in" + local dir_color="\[\033[1;35m\]" # bold purple for current working directory + local git_color="\[\033[1;36m\]" # bold cyan for Git information + local time_color="\[\033[1;32m\]" # bold green for time taken + local reset_color="\[\033[0m\]" # reset color + local prompt_symbol_color="\[\033[1;31m\]" # bold red for the prompt symbol + + local end_time=$(date +%s%3N) # current time in milliseconds + local time_taken=$(( (end_time - start_time) )) # time in milliseconds + + PS1="${user_color}ā•­ā”€\\u" # username + PS1+="${at_color}@${host_color}\\h" # @ symbol and hostname + PS1+="${in_color} in" # "in" between hostname and current directory + PS1+="${dir_color} \\w" # current working directory + + # Git information (status symbol) + PS1+=" ${git_color}$(__git_ps1 "[%s]")${reset_color}" + + if [ $time_taken -gt 0 ]; then + PS1+=" ${time_color}took ${time_taken}ms" # time taken in milliseconds + fi + + PS1+="\n${prompt_symbol_color}ā•°ā”€Ī»${reset_color} " # red color for the prompt symbol, reset color after +} + +PROMPT_COMMAND='start_time=$(date +%s%3N); set_prompt' diff --git a/themes/liquidprompt/liquidprompt.theme.bash b/themes/liquidprompt/liquidprompt.theme.bash index 60e64210c4..17458fd5f1 100644 --- a/themes/liquidprompt/liquidprompt.theme.bash +++ b/themes/liquidprompt/liquidprompt.theme.bash @@ -21,7 +21,7 @@ export LP_BATTERY_THRESHOLD=${LP_BATTERY_THRESHOLD:-75} export LP_LOAD_THRESHOLD=${LP_LOAD_THRESHOLD:-60} export LP_TEMP_THRESHOLD=${LP_TEMP_THRESHOLD:-80} - +unset _lp_legacy _lp_escape __lp_escape source "$targetdir/liquidprompt" prompt() { true; } export PS2=" ā”ƒ " @@ -29,22 +29,37 @@ export LP_PS1_PREFIX="ā”Œā”€" export LP_PS1_POSTFIX="\nā””ā–Ŗ " export LP_ENABLE_RUNTIME=0 +_lp_legacy() +{ + type -t _lp_escape &> /dev/null +} + +_lp_legacy && __lp_escape() +{ + ret="$(_lp_escape "$@")" +} + _lp_git_branch() { (( LP_ENABLE_GIT )) || return \git rev-parse --is-inside-work-tree >/dev/null 2>&1 || return - local branch + local commit branch ret + + commit="$(\git rev-parse --short -q HEAD 2>/dev/null)" + # Recent versions of Git support the --short option for symbolic-ref, but # not 1.7.9 (Ubuntu 12.04) if branch="$(\git symbolic-ref -q HEAD)"; then - _lp_escape "$(\git rev-parse --short=5 -q HEAD 2>/dev/null):${branch#refs/heads/}" + __lp_escape "$commit:${branch#refs/heads/}" + lp_vcs_branch="$ret" else # In detached head state, use commit instead # No escape needed - \git rev-parse --short -q HEAD 2>/dev/null + lp_vcs_branch="$commit" fi + _lp_legacy && echo $lp_vcs_branch || return 0 } _lp_time() { diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index d6d57e9862..2bca81c146 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -41,6 +41,8 @@ SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} NVM_THEME_PROMPT_PREFIX="" NVM_THEME_PROMPT_SUFFIX="" +NODE_THEME_PROMPT_PREFIX="" +NODE_THEME_PROMPT_SUFFIX="" NODE_CHAR=${POWERLINE_NODE_CHAR:="ā²nā³ "} NODE_THEME_PROMPT_COLOR=${POWERLINE_NODE_COLOR:=22} diff --git a/themes/powerline-naked/powerline-naked.theme.bash b/themes/powerline-naked/powerline-naked.theme.bash index cc00b3b956..934a315079 100644 --- a/themes/powerline-naked/powerline-naked.theme.bash +++ b/themes/powerline-naked/powerline-naked.theme.bash @@ -36,6 +36,8 @@ SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} NVM_THEME_PROMPT_PREFIX="" NVM_THEME_PROMPT_SUFFIX="" +NODE_THEME_PROMPT_PREFIX="" +NODE_THEME_PROMPT_SUFFIX="" NODE_CHAR=${POWERLINE_NODE_CHAR:="ā²nā³ "} NODE_THEME_PROMPT_COLOR=${POWERLINE_NODE_COLOR:=22} diff --git a/themes/powerline-plain/powerline-plain.theme.bash b/themes/powerline-plain/powerline-plain.theme.bash index 4b7aa857f7..675715287d 100644 --- a/themes/powerline-plain/powerline-plain.theme.bash +++ b/themes/powerline-plain/powerline-plain.theme.bash @@ -33,6 +33,8 @@ SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} NVM_THEME_PROMPT_PREFIX="" NVM_THEME_PROMPT_SUFFIX="" +NODE_THEME_PROMPT_PREFIX="" +NODE_THEME_PROMPT_SUFFIX="" NODE_CHAR=${POWERLINE_NODE_CHAR:="ā²nā³ "} NODE_THEME_PROMPT_COLOR=${POWERLINE_NODE_COLOR:=22} diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash index cb5c4814f9..8eff388458 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -39,6 +39,8 @@ SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} NVM_THEME_PROMPT_PREFIX="" NVM_THEME_PROMPT_SUFFIX="" +NODE_THEME_PROMPT_PREFIX="" +NODE_THEME_PROMPT_SUFFIX="" NODE_CHAR=${POWERLINE_NODE_CHAR:="ā²nā³ "} NODE_THEME_PROMPT_COLOR=${POWERLINE_NODE_COLOR:=22}