Skip to content

Commit 5f2e6ac

Browse files
committed
✨ feat: don't show tips if an abbr was used
1 parent 2ef089d commit 5f2e6ac

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

conf.d/abbr_tips.fish

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
bind " " '_abbr_tips_bind_space'
2+
bind \n '_abbr_tips_bind_newline'
3+
bind \r '_abbr_tips_bind_newline'
4+
15
function abbr_fish --on-event fish_postexec -d "Abbreviation reminder for the current command"
26
set -l command (string split ' ' "$argv")
37
set -l cmd (string replace -r -a '\\s+' ' ' "$argv" )
@@ -7,6 +11,7 @@ function abbr_fish --on-event fish_postexec -d "Abbreviation reminder for the cu
711
# or it's a function
812
if abbr -q "$cmd"
913
or ! type -q "$command[1]"
14+
or test "$_abbr_tips_is_abbr" = 1
1015
return
1116
end
1217
if test (type -t "$command[1]") = 'function'
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function _abbr_tips_bind_newline
2+
if abbr -q (string trim (commandline))
3+
set -g _abbr_tips_is_abbr 1
4+
else
5+
set -g _abbr_tips_is_abbr 0
6+
end
7+
commandline -f 'execute'
8+
end

functions/_abbr_tips_bind_space.fish

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function _abbr_tips_bind_space
2+
commandline -i " "
3+
if abbr -q (string trim (commandline))
4+
set -g _abbr_tips_is_abbr 1
5+
else
6+
set -g _abbr_tips_is_abbr 0
7+
end
8+
commandline -f 'expand-abbr'
9+
end

0 commit comments

Comments
 (0)