Skip to content

Commit

Permalink
Merge pull request #16 from matiasjrossi/master
Browse files Browse the repository at this point in the history
  • Loading branch information
gazorby authored Jun 17, 2021
2 parents 71662df + 48c886a commit 6b48f50
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions conf.d/abbr_tips.fish
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ function __abbr_tips_install --on-event abbr_tips_install
end

function __abbr_tips --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" )
set -l command (string split ' ' -- "$argv")
set -l cmd (string replace -r -a '\\s+' ' ' -- "$argv" )

# Update abbreviations lists when adding/removing abbreviations
if test "$command[1]" = "abbr"
Expand All @@ -46,7 +46,7 @@ function __abbr_tips --on-event fish_postexec -d "Abbreviation reminder for the

if string match -q '*=*' -- "$command[2]"
if test (count $command) = 2
set command_split (string split = $command[2])
set command_split (string split '=' -- $command[2])
set alias_key "a__$command_split[1]"
set alias_value $command_split[2]
set -a alias_value $command[3..-1]
Expand Down Expand Up @@ -82,7 +82,7 @@ function __abbr_tips --on-event fish_postexec -d "Abbreviation reminder for the
else if abbr -q "$cmd"
or not type -q "$command[1]"
return
else if string match -q "alias $cmd *" (alias)
else if string match -q -- "alias $cmd *" (alias)
return
else if test (type -t "$command[1]") = 'function'
and count $ABBR_TIPS_ALIAS_WHITELIST >/dev/null
Expand All @@ -100,18 +100,18 @@ function __abbr_tips --on-event fish_postexec -d "Abbreviation reminder for the
end

if test -n "$abb"
if string match -q "a__*" "$__ABBR_TIPS_KEYS[$abb]"
set -l alias (string sub -s 4 "$__ABBR_TIPS_KEYS[$abb]")
if string match -q "a__*" -- "$__ABBR_TIPS_KEYS[$abb]"
set -l alias (string sub -s 4 -- "$__ABBR_TIPS_KEYS[$abb]")
if functions -q "$alias"
echo -e (string replace -a '{{ .cmd }}' "$__ABBR_TIPS_VALUES[$abb]" \
(string replace -a '{{ .abbr }}' "$alias" "$ABBR_TIPS_PROMPT"))
echo -e (string replace -a '{{ .cmd }}' -- "$__ABBR_TIPS_VALUES[$abb]" \
(string replace -a '{{ .abbr }}' -- "$alias" "$ABBR_TIPS_PROMPT"))
else
set -e __ABBR_TIPS_KEYS[$abb]
set -e __ABBR_TIPS_VALUES[$abb]
end
else
echo -e (string replace -a '{{ .cmd }}' "$__ABBR_TIPS_VALUES[$abb]" \
(string replace -a '{{ .abbr }}' "$__ABBR_TIPS_KEYS[$abb]" "$ABBR_TIPS_PROMPT"))
echo -e (string replace -a '{{ .cmd }}' -- "$__ABBR_TIPS_VALUES[$abb]" \
(string replace -a '{{ .abbr }}' -- "$__ABBR_TIPS_KEYS[$abb]" "$ABBR_TIPS_PROMPT"))
end
end

Expand Down
2 changes: 1 addition & 1 deletion functions/__abbr_tips_bind_newline.fish
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function __abbr_tips_bind_newline
if test $__abbr_tips_used != 1
if abbr -q (string trim (commandline))
if abbr -q -- (string trim -- (commandline))
set -g __abbr_tips_used 1
else
set -g __abbr_tips_used 0
Expand Down
4 changes: 2 additions & 2 deletions functions/__abbr_tips_init.fish
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function __abbr_tips_init -d "Initialize abbreviations variables for fish-abbr-t
set -Ux __ABBR_TIPS_VALUES

set -l i 1
set -l abb (string replace -r '.*-- ' '' (abbr -s))
set -l abb (string replace -r '.*-- ' '' -- (abbr -s))
while test $i -le (count $abb)
set -l current_abb (string split -m1 ' ' "$abb[$i]")
set -a __ABBR_TIPS_KEYS "$current_abb[1]"
Expand All @@ -14,7 +14,7 @@ function __abbr_tips_init -d "Initialize abbreviations variables for fish-abbr-t
end

set -l i 1
set -l abb (string replace -r '.*-- ' '' (alias -s))
set -l abb (string replace -r '.*-- ' '' -- (alias -s))
while test $i -le (count $abb)
set -l current_abb (string split -m2 ' ' "$abb[$i]")
set -a __ABBR_TIPS_KEYS "a__$current_abb[2]"
Expand Down

0 comments on commit 6b48f50

Please sign in to comment.