Skip to content

Commit

Permalink
[zsh] Switch to Starship as a prompt provider
Browse files Browse the repository at this point in the history
I _really_ like the aesthetics of the [Pure prompt][1] and have used it
for years. However, since switching to a Yubikey and GPG certificates
for SSH, I keep running into [a bug][2] in the interaction between
pinentry-ncurses and Pure's async functionality. It mangles all future
output for the terminal, launches a spinning pinentry-curses process,
and generally wreaks havoc.

As such, I'm attempting a switch to [Starship][3] as my prompt provider
to see if that alleviates the issue. To replicate the Pure prompt's
functionality, I [patched Starship][4] locally. I intend to push this
upstream after I use it as my daily driver on both Linux and macOS for a
while.

[1]: https://github.com/sindresorhus/pure/
[2]: sindresorhus/pure#366
[3]: https://github.com/starship/starship
[4]: michaelherold/starship@cfb20c5
  • Loading branch information
michaelherold committed Sep 1, 2021
1 parent 328dc12 commit 71bb4cb
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 4 deletions.
54 changes: 54 additions & 0 deletions config/starship.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
format = """
$directory( $username$hostname)( $git_branch$git_state$git_status)( $cmd_duration)
$character
"""

add_newline = true
command_timeout = 500
scan_timeout = 30

[character]
success_symbol = "[↪](blue)"
error_symbol = "[↪](red)"
vicmd_symbol = "[↪](purple)"

[cmd_duration]
min_time = 5_000
format = "[$duration](yellow) "

[directory]
format = "[$path]($style)"
style = "blue"
truncate_to_repo = false
truncation_length = 0
truncation_symbol = "../"

[git_branch]
format = "([$branch]($style))"
style = "fg:242"

[git_state]
format = "[|$state](fg:242)"
cherry_pick = "cherry"
rebase = "rebase-i"

[git_status]
format = "([$dirty](fg:242))([ $ahead_behind](cyan))"
ahead = ""
behind = ""
conflicted = "*"
dirty = "*"
diverged = "⇣⇡"
modified = "*"
staged = "*"
untracked = "*"

[hostname]
format = "[@$hostname]($style)"
style = "fg:242"
trim_at = ""

[username]
format = "[$user]($style)"
style_root = "fg:242"
style_user = "fg:242"
12 changes: 8 additions & 4 deletions config/zsh/configs/prompt.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

[ "$TERM" = "dumb" ] && return

export PURE_PROMPT_SYMBOL=""
if command -v starship >/dev/null && [ -z "$DISABLE_STARSHIP" ]; then
eval "$(starship init zsh)"
else
export PURE_PROMPT_SYMBOL=""

fpath=("$ZDOTDIR/functions/prompt" $fpath)
fpath=("$ZDOTDIR/functions/prompt" $fpath)

autoload -U promptinit && promptinit
prompt pure
autoload -U promptinit && promptinit
prompt pure
fi

0 comments on commit 71bb4cb

Please sign in to comment.