__fish_pwd: Just always define the cygwin version

This called `uname` just to check if we *should* shorten "cygdrive"
directories.

That's more annoying than just doing it by default - on my system `pwd
| string replace` takes about 100 *micro*seconds, and this is done
once per prompt. Anyway, using $PWD further speeds it up to ~30
microseconds (compared to 10-20 for just `pwd`). This is hard to
measure because it's heavily impacted by system hitter.

The alternative is to ask cygwin to ship this feature as a patch.
This commit is contained in:
Fabian Homborg 2021-04-19 18:53:22 +02:00
parent c95a223f5e
commit dc57ba01a2

View File

@ -1,15 +1,8 @@
switch (uname)
case 'CYGWIN_*'
function __fish_pwd --description "Show current path"
function __fish_pwd --description "Show current path"
if status test-feature regex-easyesc
pwd | string replace -r '^/cygdrive/(.)?' '\U$1:'
string replace -r '^/cygdrive/(.)?' '\U$1:' -- $PWD
else
# TODO: Remove this once regex-easyesc becomes the default
pwd | string replace -r '^/cygdrive/(.)?' '\\\U$1:'
end
end
case '*'
function __fish_pwd --description "Show current path"
pwd
string replace -r '^/cygdrive/(.)?' '\\\U$1:' -- $PWD
end
end