scripts/scripts/fish/ql.fish

33 lines
698 B
Fish
Raw Normal View History

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