Add sapling status module to starship prompt
This commit is contained in:
parent
5de1b0496c
commit
2a800e601a
2 changed files with 32 additions and 0 deletions
|
@ -11,8 +11,14 @@ $git_status\
|
||||||
"""
|
"""
|
||||||
|
|
||||||
right_format = """\
|
right_format = """\
|
||||||
|
${custom.sl_status}\
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
[custom.sl_status]
|
||||||
|
command = '''~/bin/starship-sl-status'''
|
||||||
|
when = true
|
||||||
|
style = "italic bg:#79AE6F fg:#ffffff"
|
||||||
|
format = '🌱 [](fg:#79AE6F)[ $output ]($style)'
|
||||||
|
|
||||||
[character]
|
[character]
|
||||||
success_symbol = "%"
|
success_symbol = "%"
|
||||||
|
|
26
bin/starship-sl-status
Executable file
26
bin/starship-sl-status
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -xfeuo pipefail
|
||||||
|
|
||||||
|
state="${XDG_RUNTIME_DIR}/starship-sl-status"
|
||||||
|
checkout="${state}.checkout"
|
||||||
|
status="${state}.data"
|
||||||
|
|
||||||
|
if [[ "$PWD" != $(readlink -f "$state")* ]]; then
|
||||||
|
rm -f "$state"
|
||||||
|
root="$(sl root 2>/dev/null || true)"
|
||||||
|
ln -s "$root" "$state"
|
||||||
|
if [[ -z "${root}" ]]; then
|
||||||
|
echo >"${status}"
|
||||||
|
echo >"${checkout}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
saved_cid=$(cat "${checkout}" 2>/dev/null || true)
|
||||||
|
root_cid=$(cat "${state}/.sl/checkoutidentifier" || true)
|
||||||
|
if [[ ${root_cid} != "${saved_cid}" ]]; then
|
||||||
|
echo "${root_cid}" >"${checkout}"
|
||||||
|
sl log -r . -T '{if(github_pull_request_number, "#{github_pull_request_number} @ ", if(bookmarks, "{bookmarks} @ "))}{node|short}{if(remotenames, ":{remotenames}")}' >"${status}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat "$status" || true
|
Loading…
Reference in a new issue