Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add '--' to all calls to string #16

Merged
merged 2 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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