* The admone-git function is now called admone-vcs and uses Zsh's
builtin VCS information system
* Did some refactoring of the for loop in the set-prompt function
to potentially speed it up a bit
* Added software description to license file
* Removed some unecesary config variables at the start of the file
+Admone - a tolerable Zsh prompt
+
Copyright © 2020 Armaan Bhojwani
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Copyright © 2020 Armaan Bhojwani
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
![Screenshot](branding/screenshot.png)
## Installation
![Screenshot](branding/screenshot.png)
## Installation
-Source this script somewhere in your ZSHRC. Theoretically works with plugin managers as well, although this is untested
+Source this script somewhere in your Zshrc. Theoretically works with plugin managers as well, although this is untested
## Configuration
Configuration is done by modifying the variables set at the start of the script. Just get in there and mess around a bit, its not very difficult to understand
## Configuration
Configuration is done by modifying the variables set at the start of the script. Just get in there and mess around a bit, its not very difficult to understand
#######################################################################
#######################################################################
-# Admone ZSH prompt. Copyright Armaan Bhojwani. MIT licensed, see the #
+# Admone Zsh prompt. Copyright Armaan Bhojwani. MIT licensed, see the #
# LICENSE file or https://www.opensource.org/licenses/MIT for more #
# information. Git repo at https://codeberg.org/armaan/admone #
#######################################################################
# LICENSE file or https://www.opensource.org/licenses/MIT for more #
# information. Git repo at https://codeberg.org/armaan/admone #
#######################################################################
# ADMONE_BLOCK_SEPARATOR="∙"
ADMONE_BLOCK_LEFT="["
ADMONE_BLOCK_RIGHT="]"
# ADMONE_BLOCK_SEPARATOR="∙"
ADMONE_BLOCK_LEFT="["
ADMONE_BLOCK_RIGHT="]"
- # ADMONE_BLOCK_LEFT="{"
- # ADMONE_BLOCK_RIGHT="}"
# ADMONE_BLOCK_LEFT="("
# ADMONE_BLOCK_RIGHT=")"
# ADMONE_BLOCK_LEFT="("
# ADMONE_BLOCK_RIGHT=")"
-ADMONE_VI_MODE_CURSOR="1"
- # ADMONE_VI_MODE_CURSOR="1"
ADMONE_SHOW_0_EXIT_CODE="0"
ADMONE_SHOW_0_EXIT_CODE="0"
-ADMONE_INCLUDE="admone-pwd;admone-git;admone-exit-code"
+ADMONE_INCLUDE="admone-pwd;admone-vcs;admone-exit-code"
ADMONE_FORMAT_LOWER="%B%F{%(?.cyan.red)}"
ADMONE_FORMAT_LOWER="%B%F{%(?.cyan.red)}"
+zstyle ':vcs_info:git:*' formats '%b%u%c'
+zstyle ':vcs_info:git:*' actionformats '%b|%a%u%c'
+zstyle ':vcs_info:*' unstagedstr ' *'
+zstyle ':vcs_info:*' stagedstr ' +'
+
admone-pwd() {
echo "%F{blue}%~%f"
}
admone-pwd() {
echo "%F{blue}%~%f"
}
-admone-git() {
- git_branch="$(git rev-parse --abbrev-ref HEAD 2>/dev/null)"
- echo "%F{green}${git_branch}%f"
+admone-vcs() {
+ echo "%F{green}${vcs_info_msg_0_}%f"
}
admone-exit-code() {
([[ $ADMONE_SHOW_0_EXIT_CODE == "1" ]] && echo "%(?,%F{cyan}%?%f,%F{red}%?%f)") ||
}
admone-exit-code() {
([[ $ADMONE_SHOW_0_EXIT_CODE == "1" ]] && echo "%(?,%F{cyan}%?%f,%F{red}%?%f)") ||
- echo "%(?,,%F{red}%?%f)"
+ echo "%(?,,%F{red}%?%f)"
}
admone-date() {
echo $(date -I)
}
admone-date() {
echo $(date -I)
# Cursor shape depends on vi mode
function zle-keymap-select zle-line-init zle-line-finish {
# Cursor shape depends on vi mode
function zle-keymap-select zle-line-init zle-line-finish {
- if [[ $ADMONE_VI_MODE_CURSOR == "1" ]]; then
- case $KEYMAP in
- vicmd)
- # Block
- print -n -- "\E]50;CursorShape=0\C-G"
- ;;
- viins|main)
- # Beam
- print -n -- "\E]50;CursorShape=1\C-G"
- ;;
- esac
- zle reset-prompt
- zle -R
- fi
+ case $KEYMAP in
+ vicmd)
+ # Block
+ print -n -- "\E]50;CursorShape=0\C-G"
+ ;;
+ viins|main)
+ # Beam
+ print -n -- "\E]50;CursorShape=1\C-G"
+ ;;
+ esac
+ zle reset-prompt
+ zle -R
# Add in functions as defined above
NUM_FUNCS="$(echo $ADMONE_INCLUDE | grep -o ';' | wc -l)"
# Add in functions as defined above
NUM_FUNCS="$(echo $ADMONE_INCLUDE | grep -o ';' | wc -l)"
- for (( i = 0; i <= $NUM_FUNCS; i++ )); do
- THE_COMMAND="$(echo $ADMONE_INCLUDE | cut -d ';' -f $(($i + 1)))"
- [[ $i == 0 ]] && upper+="$ADMONE_BLOCK_LEFT$($THE_COMMAND)$ADMONE_BLOCK_RIGHT"
- [[ $i == 0 ]] || upper+="$ADMONE_BLOCK_SEPARATOR$ADMONE_BLOCK_LEFT$($THE_COMMAND)$ADMONE_BLOCK_RIGHT"
+
+ THE_COMMAND="$(echo $ADMONE_INCLUDE | cut -d ';' -f 1)"
+ upper+="$ADMONE_BLOCK_LEFT$($THE_COMMAND)$ADMONE_BLOCK_RIGHT"
+
+ for (( i = 0; i < $NUM_FUNCS; i++ )); do
+ THE_COMMAND="$(echo $ADMONE_INCLUDE | cut -d ';' -f $(($i + 2)))"
+ upper+="$ADMONE_BLOCK_SEPARATOR$ADMONE_BLOCK_LEFT$($THE_COMMAND)$ADMONE_BLOCK_RIGHT"
+if [[ ! $(echo $ADMONE_INCLUDE | grep -q "vcs") ]]; then
+ zstyle ':vcs_info:*' check-for-changes true
+ autoload -Uz add-zsh-hook vcs-info
+ add-zsh-hook precmd vcs_info
+ add-zsh-hook precmd set-prompt
+else
+ autoload -Uz add-zsh-hook
+ add-zsh-hook precmd set-prompt
+fi
+
zle -N zle-line-init
zle -N zle-line-finish
zle -N zle-keymap-select
zle -N zle-line-init
zle -N zle-line-finish
zle -N zle-keymap-select
-autoload -Uz add-zsh-hook
-add-zsh-hook precmd set-prompt