Files
gitnow/crates/gitnow/include/shell/zsh.sh
kjuulh b5394a6b26
Some checks failed
continuous-integration/drone/push Build encountered an error
feat: add chooser file mechanism for shell directory switching
Replace stdout-based path capture with a temporary chooser file that the
shell wrapper reads after gitnow exits. Commands that select a directory
write to the file; commands that don't (e.g. project delete) leave it
empty, so the shell only cd's when appropriate. The chooser file path
can be set via --chooser-file flag or GITNOW_CHOOSER_FILE env var.
2026-03-20 14:39:42 +01:00

34 lines
652 B
Bash

function git-now {
# Run an update in the background
(
nohup gitnow update > /dev/null 2>&1 &
)
# Create a temporary chooser file
local chooser_file
chooser_file="$(mktemp)"
# Run gitnow with the chooser file
GITNOW_CHOOSER_FILE="$chooser_file" gitnow "$@"
local exit_code=$?
if [[ $exit_code -ne 0 ]]; then
rm -f "$chooser_file"
return $exit_code
fi
# If the chooser file has content, cd to the chosen path
if [[ -s "$chooser_file" ]]; then
local target
target="$(cat "$chooser_file")"
rm -f "$chooser_file"
cd "$target"
else
rm -f "$chooser_file"
fi
}
function gn {
git-now "$@"
}