Skip to content

Instantly share code, notes, and snippets.

@thefotios
Last active July 11, 2025 13:50
Show Gist options
  • Save thefotios/ca47a93a785a68f11332157e3a4c0bad to your computer and use it in GitHub Desktop.
Save thefotios/ca47a93a785a68f11332157e3a4c0bad to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
###
# https://gist.github.com/thefotios/ca47a93a785a68f11332157e3a4c0bad
#
# zed doesn't handle waiting for directories
# See https://github.com/zed-dev/zed/issues/23347
#
# This script checks to see if any of the arguments are
# directories and if so, creates a temporary file to wait for
# Thus tricking the mighty zed and saving the day!
####
path=("${@}")
for item in "${path[@]}"
do
if [ -d "$item" ]; then
tmpfile=$(mktemp -t close-zed.XXXXX)
trap 'rm "$tmpfile"' EXIT
path+=("$tmpfile")
echo "Close this tab when done" > "$tmpfile"
break
fi
done
zed --wait "${path[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment