scripts/scripts/fish/ql

35 lines
719 B
Plaintext
Raw Normal View History

2019-08-18 06:26:48 -07:00
#!/usr/bin/env fish
2019-06-24 06:23:58 -07:00
function ql -d 'Changes directory to a quicklink' -a name
2019-07-05 19:09:01 -07:00
if not set -q quicklink_$name name
echo (set_color red)"error: no quicklink named $name"(set_color normal)
return
end
2019-06-24 06:23:58 -07:00
2019-07-05 19:09:01 -07:00
set name quicklink_$name
2019-06-24 06:23:58 -07:00
2019-07-05 19:09:01 -07:00
cd $$name
2019-06-24 06:23:58 -07:00
end
function ql-r -w ql -d 'Removes a quicklink' -a name
2019-07-05 19:09:01 -07:00
if not set -q name
echo (set_color red)"error: not enough arguments"(set_color normal)
return
end
2019-06-24 06:23:58 -07:00
2019-07-05 19:09:01 -07:00
set -Ue quicklink_$name
2019-06-24 06:23:58 -07:00
end
function ql-s -d 'Saves the working directory as a quicklink' -a name
2019-07-05 19:09:01 -07:00
if not set -q name
echo (set_color red)"error: not enough arguments"(set_color normal)
return
end
2019-06-24 06:23:58 -07:00
2019-07-05 19:09:01 -07:00
set -U quicklink_$name $PWD
2019-06-24 06:23:58 -07:00
end
complete -c ql -xa '(set -U | rg -or \'$1\' \'^quicklink_(.+) \')'
## EOF