aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/shell/atuin.fish
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-11 16:10:29 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-11 16:10:29 +0200
commit97f207b771b94c5285faae4810d6eeda1b78926b (patch)
tree4482544233c30e0e9a62be6afcfe92c8e01b0a50 /crates/turtle/src/shell/atuin.fish
parentchore: Remove all `pub`s (diff)
downloadatuin-97f207b771b94c5285faae4810d6eeda1b78926b.zip
chore(server): Simplify the database support
Diffstat (limited to 'crates/turtle/src/shell/atuin.fish')
-rw-r--r--crates/turtle/src/shell/atuin.fish86
1 files changed, 5 insertions, 81 deletions
diff --git a/crates/turtle/src/shell/atuin.fish b/crates/turtle/src/shell/atuin.fish
index 15b33451..2b469383 100644
--- a/crates/turtle/src/shell/atuin.fish
+++ b/crates/turtle/src/shell/atuin.fish
@@ -37,49 +37,6 @@ function _atuin_postexec --on-event fish_postexec
set --erase ATUIN_HISTORY_ID
end
-# Check if tmux popup is available (tmux >= 3.2)
-function _atuin_tmux_popup_check
- if not test -n "$TMUX"
- echo 0
- return
- end
-
- if test "$ATUIN_TMUX_POPUP" = false
- echo 0
- return
- end
-
- set -l tmux_version (tmux -V 2>/dev/null | string match -r '\d+\.\d+')
- if not test -n "$tmux_version"
- echo 0
- return
- end
-
- set -l parts (string split '.' $tmux_version)
- set -l m1 $parts[1]
- set -l m2 0
- if test (count $parts) -ge 2
- set m2 $parts[2]
- end
-
- if not string match -rq '^[0-9]+$' -- "$m1"
- echo 0
- return
- end
-
- if not string match -rq '^[0-9]+$' -- "$m2"
- set m2 0
- end
-
- if test "$m1" -gt 3 2>/dev/null; or begin
- test "$m1" -eq 3 2>/dev/null; and test "$m2" -ge 2 2>/dev/null
- end
- echo 1
- else
- echo 0
- end
-end
-
function _atuin_search
set -l keymap_mode
switch $fish_key_bindings
@@ -94,47 +51,14 @@ function _atuin_search
set keymap_mode emacs
end
- set -l use_tmux_popup (_atuin_tmux_popup_check)
-
set -l ATUIN_H
set -l ATUIN_STATUS 0
- if test "$use_tmux_popup" -eq 1
- set -l tmpdir (mktemp -d)
- if not test -d "$tmpdir"
- # if mktemp got errors
- set ATUIN_H (ATUIN_SHELL=fish ATUIN_LOG=error ATUIN_QUERY=(commandline -b) atuin search --keymap-mode=$keymap_mode $argv -i 3>&1 1>&2 2>&3 3>&- | string collect)
- set ATUIN_STATUS $pipestatus[1]
- else
- set -l result_file "$tmpdir/result"
- set -l query (commandline -b | string replace -a "'" "'\\''")
- set -l escaped_args ""
- for arg in $argv
- set escaped_args "$escaped_args '"(string replace -a "'" "'\\''" -- $arg)"'"
- end
-
- # In the popup, atuin goes to terminal, stderr goes to file
- set -l cdir (pwd)
- # Keep default value anyways
- set -l popup_width (test -n "$ATUIN_TMUX_POPUP_WIDTH" && echo "$ATUIN_TMUX_POPUP_WIDTH" || echo "80%")
- set -l popup_height (test -n "$ATUIN_TMUX_POPUP_HEIGHT" && echo "$ATUIN_TMUX_POPUP_HEIGHT" || echo "60%")
- tmux display-popup -d "$cdir" -w "$popup_width" -h "$popup_height" -E -E -- \
- sh -c "PATH='$PATH' ATUIN_SESSION='$ATUIN_SESSION' ATUIN_SHELL=fish ATUIN_LOG=error ATUIN_QUERY='$query' atuin search --keymap-mode=$keymap_mode$escaped_args -i 2>'$result_file'"
- set ATUIN_STATUS $status
-
- if test -f "$result_file"
- set ATUIN_H (cat "$result_file" | string collect)
- end
-
- command rm -rf "$tmpdir"
- end
- else
- # In fish 3.4 and above we can use `"$(some command)"` to keep multiple lines separate;
- # but to support fish 3.3 we need to use `(some command | string collect)`.
- # https://fishshell.com/docs/current/relnotes.html#id24 (fish 3.4 "Notable improvements and fixes")
- set ATUIN_H (ATUIN_SHELL=fish ATUIN_LOG=error ATUIN_QUERY=(commandline -b) atuin search --keymap-mode=$keymap_mode $argv -i 3>&1 1>&2 2>&3 3>&- | string collect)
- set ATUIN_STATUS $pipestatus[1]
- end
+ # In fish 3.4 and above we can use `"$(some command)"` to keep multiple lines separate;
+ # but to support fish 3.3 we need to use `(some command | string collect)`.
+ # https://fishshell.com/docs/current/relnotes.html#id24 (fish 3.4 "Notable improvements and fixes")
+ set ATUIN_H (ATUIN_SHELL=fish ATUIN_LOG=error ATUIN_QUERY=(commandline -b) atuin search --keymap-mode=$keymap_mode $argv -i 3>&1 1>&2 2>&3 3>&- | string collect)
+ set ATUIN_STATUS $pipestatus[1]
if test "$ATUIN_STATUS" -ne 0
test -n "$ATUIN_H"; and printf '%s\n' "$ATUIN_H" >&2