File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 1
- function __fasd_run -e fish_postexec -d " fasd takes record of the directories changed into"
1
+ function __fasd_expand_vars -d " Expands only the first occurance of a variable in the passed string without evaluating the string"
2
+ set -lx vars (echo -n $argv | grep -oP ' (?!\\\\ )\ $\ K([A-z_][A-z0-9_]*?)([^A-z0-9_]|\ b|\ n)' | perl -pe ' s/(.+?)(?:[^A-z0-9_]|\ b)$/\ 1\ n/' | sort -u )
3
+ for var in $vars
4
+ # Only replace if the variable is defined
5
+ if set -q $var
6
+ # Replacing the variable once is enough
7
+ set argv (string replace -r ' ([^\\\\ ]|\ b)\ $' " $var " ' $1' " $$var " " $argv " )
8
+ end
9
+ end
10
+ # The following pipe does the same thing as fasd --sanitize
11
+ printf ' %s\\ n' " $argv " | sed -e ' s/\ ([^\ ]\ )$( *[^ ]* *\ ([^)]*\ )))*/\ 1\ 2/g' -e ' s/\ ([^\ ]\ )[|&;<>$`{}]\ {1,\ }/\ 1 /g' | tr -s " " \n
12
+ end
13
+
14
+ function __fasd_run -e fish_postexec -d " fasd records the directories changed into"
2
15
set -lx RETVAL $status
3
16
if test $RETVAL -eq 0 # if there was no error
4
- command fasd --proc (command fasd --sanitize ( eval echo " $argv " ) | tr -s " " \n ) > " /dev/null" 2>&1 &
17
+ command fasd --proc (__fasd_expand_vars $argv ) > " /dev/null" 2>&1 &
5
18
end
6
19
end
You can’t perform that action at this time.
0 commit comments