Created
April 28, 2021 13:16
-
-
Save SkyyySi/0ab432c27aaa24ced8c689d3abc013c4 to your computer and use it in GitHub Desktop.
Make zsh look like systemd..!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
setopt prompt_subst | |
PROMPT=$'[%(?. %2FOK%f .%1FFAILED%f)] %(?.$(echo "Started ${history[$(( $HISTCMD - 1 ))]}").$(echo "Failed to start ${history[$(( $HISTCMD - 1 ))]}")).\n> ' | |
RPROMPT='%3~' | |
zle-line-init() { | |
emulate -L zsh | |
[[ $CONTEXT == start ]] || return 0 | |
while true; do | |
zle .recursive-edit | |
local -i ret=$? | |
[[ $ret == 0 && $KEYS == $'\4' ]] || break | |
[[ -o ignore_eof ]] || exit 0 | |
done | |
local saved_prompt=$PROMPT | |
local saved_rprompt=$RPROMPT | |
#PROMPT='%# ' | |
PROMPT=$'[%(?. %2FOK%f .%1FFAILED%f)] %(?.$(echo "Started ${history[$(( $HISTCMD - 1 ))]}").$(echo "Failed to start ${history[$(( $HISTCMD - 1 ))]}")).' | |
RPROMPT='' | |
zle .reset-prompt | |
PROMPT=$saved_prompt | |
RPROMPT=$saved_rprompt | |
if (( ret )); then | |
zle .send-break | |
else | |
zle .accept-line | |
fi | |
return ret | |
} | |
zle -N zle-line-init |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment