punkfairie
60cb5740d7
Add .config/fish/functions/__ysu__check_aliases.fish Add .config/fish/functions/__ysu__check_git_aliases.fish Add .config/fish/functions/__ysu__check_hardcore.fish Add .config/fish/functions/__ysu__flush_buffer.fish Add .config/fish/functions/__ysu__get_field.fish Add .config/fish/functions/__ysu__message.fish Add .config/fish/functions/__ysu__set_default.fish Add .config/fish/functions/__ysu__set_field.fish Add .config/fish/functions/__ysu__write_buffer.fish
24 lines
921 B
Fish
24 lines
921 B
Fish
function __ysu__check_aliases \
|
|
--on-event fish_preexec
|
|
string match --quiet "sudo *" "$argv"; and return
|
|
|
|
set --local found false
|
|
alias | sort | while read entry
|
|
set entry (string replace "=" "" "$entry")
|
|
set --local tokens (string split --max 2 " " "$entry")
|
|
set --local key "$tokens[2]"
|
|
set --local escaped_key (string escape --no-quote --style=regex "$key")
|
|
|
|
string match --quiet --regex "$escaped_key" "$YSU__IGNORED_GLOBAL_ALIASES"; and continue
|
|
|
|
set --local value (string replace --regex '(?:[\"|\']([^,]*)[\"|\'])' '$1' "$tokens[3]")
|
|
set --local escaped_value (string escape --no-quote --style=regex "$value")
|
|
|
|
if string match --quiet --regex "(?<=^|\s)$escaped_value(?=\s|\$)" "$argv"
|
|
__ysu__message "alias" "$value" "$key"
|
|
set found true
|
|
end
|
|
end
|
|
|
|
"$found"; and __ysu__check_hardcore
|
|
end
|