Skip to content

Commit

Permalink
cmd/setup/fish: setup script for recording commands.
Browse files Browse the repository at this point in the history
NOTE: aliases in fish are functions and can have branches.

pre and postexec hooks don't tell us the exact commands evaluated, just
the commandline passed in to it.
  • Loading branch information
joshi4 committed Sep 17, 2024
1 parent aca8595 commit 83b7fb6
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions cmd/setup/savvy.fish
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,29 @@ __savvy_modify_prompt



function __savvy_record_pre_exec__ --on-event fish_preexec
function __savvy_record_pre_exec__ --on-event fish_postexec
if not test "$SAVVY_CONTEXT" = "record"
return
end

# $argv[2] is the full command line in Fish
set -l cmd $argv[2]
set -l cmd $argv[1]

# Clear step_id
set -g step_id ""

if test "$SAVVY_CONTEXT" = "record"
# Get the current prompt
set -l prompt (fish_prompt)
#set -l prompt (fish_prompt)

# Remove color codes and other formatting from the prompt
set -l clean_prompt (string replace -ra '\e\[[^m]*m' "" -- $prompt)
#set -l clean_prompt (string replace -ra '\e\[[^m]*m' "" -- $prompt)

# Send command to savvy and get step_id
#savvy send --prompt="$clean_prompt" $cmd
set -g step_id (
env SAVVY_SOCKET_PATH=$SAVVY_INPUT_FILE \
savvy send --prompt="$clean_prompt" $cmd
savvy send $cmd
)
end
end

0 comments on commit 83b7fb6

Please sign in to comment.