A tolerable ZSH prompt
## 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
## My design requirements
- - No OhMyZSH dependency
- - Fast to load
+ - No dependency on OhMyZSH
+ - Quick to load
- 2 lines
- Git intergration
- Easily extensible
ADMONE_BLOCK_SEPARATOR="-"
ADMONE_BLOCK_LEFT="["
ADMONE_BLOCK_RIGHT="]"
-ADMONE_INCLUDE="admone-pwd;admone-git;admone-exit-code;admone-12hr"
+ADMONE_VI_MODE_CURSOR="1"
+ADMONE_INCLUDE="admone-pwd;admone-git;admone-exit-code;admone-12hr;admone-time"
function admone-pwd {
echo "%F{blue}%~%f%F{240}"
function admone-exit-code {
echo "%(?,,%F{1}%?%F{240})"
}
-
function admone-date {
echo $(date -I)
}
function admone-24hr {
echo $(date +%x)
}
+function admone-time {
+ # Intergration with https://codeberg.org/armaan/zsh-command-time
+ echo %F{cyan}$timer_show%f
+}
+
#######################################################################
#
# Cursor shape depends on vi mode
function zle-keymap-select zle-line-init zle-line-finish {
- case $KEYMAP in
- vicmd)
- print -n -- "\E]50;CursorShape=0\C-G"
- ;;
- viins|main)
- print -n -- "\E]50;CursorShape=1\C-G"
- ;;
- *)
- ;;
- esac
+ if [[ $ADMONE_VI_MODE_CURSOR == 1 ]]; then
+ case $KEYMAP in
+ vicmd)
+ print -n -- "\E]50;CursorShape=0\C-G"
+ ;;
+ viins|main)
+ print -n -- "\E]50;CursorShape=1\C-G"
+ ;;
+ *)
+ ;;
+ esac
- zle reset-prompt
- zle -R
+ zle reset-prompt
+ zle -R
+ fi
}
function set-prompt() {
- upper="%B${ADMONE_PRE_UPPER}"
- lower="%B${ADMONE_PRE_LOWER}%B%F{%(?.cyan.red)}${ADMONE_PROMPT_CHAR}%f%b "
+ upper="${ADMONE_PRE_UPPER}"
+ lower="${ADMONE_PRE_LOWER}%B%F{%(?.cyan.red)}${ADMONE_PROMPT_CHAR}%f%b "
NUM_FUNCS="$(echo $ADMONE_INCLUDE | grep -o ';' | wc -l)"
REAL_NUM_FUNCS=$((NUM_FUNCS+1))
-
+
for (( i = 0; i <= $NUM_FUNCS; i++ )); do
(( val = $i + 1 ))
THE_COMMAND="$(echo $ADMONE_INCLUDE | cut -d ';' -f $val)"