mirror of
https://github.com/prdlk/dotfiles.git
synced 2026-11-02 11:32:42 +00:00
Fix atuin-pick: resolve atuin outside kitty PATH, rename to atuin-pick
This commit is contained in:
1 parent
0b28d234ac
commit
b2d81c31d2
2 files changed
+9
-5
No files matched your search
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python3
|
||||
"""atuin-pick: atuin history picker for a kitty split (ctrl+shift+p).
|
||||
|
||||
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
|
||||
directory. Run the selection with rc loaded so aliases and functions
|
||||
resolve — its output stays in this split — then drop to an interactive
|
||||
shell.
|
||||
"""
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# 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 = shutil.which("atuin") or os.path.expanduser("~/.atuin/bin/atuin")
|
||||
if "ATUIN_SESSION" not in os.environ:
|
||||
os.environ["ATUIN_SESSION"] = subprocess.run(
|
||||
[atuin, "uuid"], stdout=subprocess.PIPE, text=True
|
||||
).stdout.strip()
|
||||
|
||||
sel = subprocess.run(
|
||||
[atuin, "search", "-i", "--filter-mode", "directory"],
|
||||
stdout=subprocess.PIPE,
|
||||
text=True,
|
||||
).stdout.strip()
|
||||
if sel:
|
||||
print(f"\u276f {sel}", file=sys.stderr)
|
||||
subprocess.run(["zsh", "-ic", "--", sel])
|
||||
os.execvp("zsh", ["zsh", "-i"])
|
||||
Reference in new issue
Block a user