Skip to content

Commit

Permalink
πŸ› fix: properly resetting abbr status
Browse files Browse the repository at this point in the history
  • Loading branch information
gazorby committed Apr 13, 2020
1 parent 46c70c1 commit 59e90e2
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions conf.d/abbr_tips.fish
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ function abbr_fish --on-event fish_postexec -d "Abbreviation reminder for the cu
set -l command (string split ' ' "$argv")
set -l cmd (string replace -r -a '\\s+' ' ' "$argv" )

# Exit if either command is already an abbreviation
# or not found
# or it's a function
if abbr -q "$cmd"
if test $_abbr_tips_is_abbr = 1
set -g _abbr_tips_is_abbr 0
return
else if abbr -q "$cmd"
or ! type -q "$command[1]"
or test $_abbr_tips_is_abbr = 1
return
end
if test (type -t "$command[1]") = 'function'
else if test (type -t "$command[1]") = 'function'
and ! contains "$command[1]" $ABBR_TIPS_ALIAS_WHITELIST
return
end
Expand All @@ -32,7 +30,6 @@ function abbr_fish --on-event fish_postexec -d "Abbreviation reminder for the cu
or set -l abb (contains -i -- (string replace -r -a '((-{1,2})\\w+)(\\s\\S+)' '$1' "$cmd") $_ABBR_TIPS_VALUES)
or set -l abb (contains -i -- (string replace -r -a '(^( ?\\w+){2}).*' '$1' "$cmd") $_ABBR_TIPS_VALUES)
or set -l abb (contains -i -- (string replace -r -a '(^( ?\\w+){3}).*' '$1' "$cmd") $_ABBR_TIPS_VALUES)
set -g _abbr_tips_is_abbr 0
echo -e "\nπŸ’‘ \e[1m$_ABBR_TIPS_KEYS[$abb]\e[0m => $_ABBR_TIPS_VALUES[$abb]"
return
end
Expand Down

0 comments on commit 59e90e2

Please sign in to comment.