Skip to content

Commit

Permalink
✨ feat: don't show tips if an abbr was used
Browse files Browse the repository at this point in the history
  • Loading branch information
gazorby committed Apr 13, 2020
1 parent 2ef089d commit 5f2e6ac
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions conf.d/abbr_tips.fish
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
bind " " '_abbr_tips_bind_space'
bind \n '_abbr_tips_bind_newline'
bind \r '_abbr_tips_bind_newline'

function abbr_fish --on-event fish_postexec -d "Abbreviation reminder for the current command"
set -l command (string split ' ' "$argv")
set -l cmd (string replace -r -a '\\s+' ' ' "$argv" )
Expand All @@ -7,6 +11,7 @@ function abbr_fish --on-event fish_postexec -d "Abbreviation reminder for the cu
# or it's a function
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'
Expand Down
8 changes: 8 additions & 0 deletions functions/_abbr_tips_bind_newline.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function _abbr_tips_bind_newline
if abbr -q (string trim (commandline))
set -g _abbr_tips_is_abbr 1
else
set -g _abbr_tips_is_abbr 0
end
commandline -f 'execute'
end
9 changes: 9 additions & 0 deletions functions/_abbr_tips_bind_space.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function _abbr_tips_bind_space
commandline -i " "
if abbr -q (string trim (commandline))
set -g _abbr_tips_is_abbr 1
else
set -g _abbr_tips_is_abbr 0
end
commandline -f 'expand-abbr'
end

0 comments on commit 5f2e6ac

Please sign in to comment.