Hello,
I recently switched from zsh to fish and am currently trying to port my
version of Mikael Magnusson's rationalise-dot to fish. The basic
functionality (automatically expanding each '.' after an initial '..' to
a new '/..') is fairly straightforward and probably known to most of
you:
function rationalise_dot
if commandline -t | sgrep -q '\(^\|/\)\.\.$'
commandline -i /..
else
commandline -i .
end
end
function fish_user_key_bindings
bind . rationalise_dot
end
However, my version had another feature that I find extremely handy: It
displays the path that the current '../../.. etc' expands to beneath the
commandline, like this:
$ cd /a/b/c/d/e
$ cd ../
/a/b/c/d <- this is automatically displayed below the
commandline, not the output of the cd command
$ cd ../../
/a/b/c/ <- ditto
And so on. The zsh code looks like this:
rationalise-dot() {
local MATCH dir split
split=(${(z)LBUFFER})
if (( $#split > 1 )); then
dir=$split[-1]
else
dir=$split
fi
if [[ $LBUFFER =~ '(^|/| | |'$'\n''|\||;|&)\.\./$' ]]; then
zle self-insert
zle self-insert
LBUFFER+=/
[[ -e $dir ]] && zle -M $dir(:a:h)
elif [[ $LBUFFER[-1] == '.' ]]; then
zle self-insert
LBUFFER+=/
[[ -e $dir ]] && zle -M $dir(:a:h)
else
zle self-insert
fi
}
Is there a way to get this functionality in fish? Autocomplete
suggestions in fish are already displayed in a similar fashion, but as
far as I can tell, this is a core functionality of fish and the ability
to display arbitrary information below the commandline is not exposed as
a callable function. Or am I mistaken?
This is obviously a minor quibble but I would appreciate it if someone
had suggestions as to how to go about implementing it.
Best regards
------------------------------------------------------------------------------
Full-scale, agent-less Infrastructure Monitoring from a single dashboard
Integrate with 40+ ManageEngine ITSM Solutions for complete visibility
Physical-Virtual-Cloud Infrastructure monitoring from one console
Real user monitoring with APM Insights and performance trend reports
Learn More http://pubads.g.doubleclick.net/gampad/clk?id=247754911&iu=/4140
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users