Skip to content

Commit

Permalink
feat(binaries): allow create a new directory
Browse files Browse the repository at this point in the history
  • Loading branch information
spywhere committed Sep 19, 2024
1 parent 1600648 commit f759ff7
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions binaries/work
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ if test "$1" = "-"; then
"$command" "$WORKSPACE" || exit
return
elif test -n "$@"; then
query="-q $*"
query="--query=$*"
fi

output="$(find "$WORKSPACE" -mindepth 1 -maxdepth 3 -type d -name '.git' | rev | cut -d'/' -f2- | rev | fzf --height=20 --print-query '--preview=git -C {} branch' '--bind=ctrl-/:toggle-preview' "$query")"
query="$(echo "$output" | sed -n 1p)"
selection="$(echo "$output" | sed -n 2p)"
if test -n "$selection"; then
"$command" "$selection" || exit
elif test -z "$selection" && test "$command" = "cd"; then
printf "Create %s? [y/N] " "$WORKSPACE/$query"
while true; do
read -r REPLY
case "$REPLY" in
y|Y)
mkdir -p "$WORKSPACE/$query" || exit
"$command" "$WORKSPACE/$query" || exit
break
;;
*)
break
;;
esac
done
fi
"$command" "$(find "$WORKSPACE" -mindepth 1 -maxdepth 3 -type d -name '.git' | rev | cut -d'/' -f2- | rev | fzf --height=20 '--preview=git -C {} branch' '--bind=ctrl-/:toggle-preview' "$query")" || exit

0 comments on commit f759ff7

Please sign in to comment.