Last active
May 26, 2026 08:50
-
-
Save ghiden/e5061bd293c5df53c99a10ed79c3d0f9 to your computer and use it in GitHub Desktop.
zk edit interactive loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # zk interactive loop | |
| zkloop() { | |
| # set current directory name | |
| print -Pn "\e]2;%1~\a" | |
| while true; do | |
| local flag=$(mktemp) | |
| local wrapper=$(mktemp) | |
| # We hardcode your actual editor here (e.g., nvim) so nothing gets lost | |
| cat <<-EOF > "$wrapper" | |
| #!/bin/sh | |
| echo 1 > "$flag" | |
| exec nvim "\$@" | |
| EOF | |
| chmod +x "$wrapper" | |
| # ZK_EDITOR overrides everything, including zk's config.toml | |
| ZK_EDITOR="$wrapper" zk edit -i --sort modified- | |
| local was_launched=$(cat "$flag") | |
| rm -f "$flag" "$wrapper" | |
| # If empty, the editor never launched (you pressed Esc/Ctrl-C) | |
| if [ -z "$was_launched" ]; then | |
| break | |
| fi | |
| clear | |
| done | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment