atuin-pick: run selection in interactive fish via --init-command

This commit is contained in:
Prad Nukala committed 2026-08-14 14:03:50 -04:00
1 parent ed81583e02
commit 4fabb40040
1 file changed
+8 -7
+8 -7
View File
@@ -3,14 +3,14 @@
atuin search -i draws its TUI on the tty and prints the selected command atuin search -i draws its TUI on the tty and prints the selected command
to stdout (Esc prints nothing). Filter to history from the current to stdout (Esc prints nothing). Filter to history from the current
directory. Run the selection with rc loaded so aliases and functions directory. Hand the selection to an interactive fish via --init-command:
resolve — its output stays in this split — then drop to an interactive it runs inside that shell (aliases/abbr resolve, cd persists) with its
shell. output in the split, and the prompt drops down below it.
""" """
import os import os
import shlex
import shutil import shutil
import subprocess import subprocess
import sys
# kitty's launch env has neither ~/.atuin/bin on PATH nor ATUIN_SESSION # kitty's launch env has neither ~/.atuin/bin on PATH nor ATUIN_SESSION
# (atuin's shell init never ran), so resolve and seed both here. # (atuin's shell init never ran), so resolve and seed both here.
@@ -25,7 +25,8 @@ sel = subprocess.run(
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
text=True, text=True,
).stdout.strip() ).stdout.strip()
argv = ["fish"]
if sel: if sel:
print(f"\u276f {sel}", file=sys.stderr) argv += ["-C", f"echo {shlex.quote('\u276f ' + sel)}; {sel}"]
subprocess.run(["zsh", "-ic", "--", sel]) os.execvp("fish", argv)
os.execvp("zsh", ["zsh", "-i"])