From fc3f29f227510de42e171af006f5c2dda0ca5eec Mon Sep 17 00:00:00 2001 From: Luis Guilherme Coelho Date: Mon, 29 Jan 2024 21:21:07 -0300 Subject: [PATCH] files: fish: Fix behavior of some custom fish functions --- .../fish/functions/fish_custom_functions.fish | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/files/fish/functions/fish_custom_functions.fish b/files/fish/functions/fish_custom_functions.fish index a243454..678465e 100644 --- a/files/fish/functions/fish_custom_functions.fish +++ b/files/fish/functions/fish_custom_functions.fish @@ -38,10 +38,20 @@ end function bang-bang-k set -l k (string replace '!!:' '' $argv[1]) - set -l arr (string replace -ra ' ' '\n' $history[1]) + set -l arr (string replace -ra '([^\\\ ])( |\n)+' '$1\n' $history[1]) echo $arr[$k] end +function bang-dollar + set -l arr (string replace -ra '([^\\\ ])( |\n)+' '$1\n' $history[1]) + echo $arr[-1] +end + +function bang-star + set -l arr (string replace -ra '([^\\\ ])( |\n)+' '$1\n' $history[1]) + echo $arr[..-2] +end + function edit-home echo "~/projects/code/scm/radix/ && $EDITOR home-environments/$(whoami).scm" end @@ -49,11 +59,3 @@ end function edit-system echo "~/projects/code/scm/radix/ && $EDITOR operating-systems/$(hostname).scm" end - -function bang-dollar - string replace -ra '.* ' '' "$history[1]" -end - -function bang-star - string replace -ra ' [^ ]+$' '' "$history[1]" -end