Hey Jakob,
I thought I'd chime in with the implementation I have running, just for the
sake of completion:
fish -v
fish, version 2.1.2-1228-g89da096
.config/fish/functions/expand-dot-to-parent-directory-path.fish :
function expand-dot-to-parent-directory-path -d 'expand ... to ../.. etc'
# Get commandline up to cursor
set -l cmd (commandline --cut-at-cursor)
# Match last line
switch $cmd[-1]
case '*..'
commandline --insert '/..'
case '*'
commandline --insert '.'
end
end
.config/fish/config.fish :
function fish_user_key_bindings
bind . 'expand-dot-to-parent-directory-path'
end
Now, mine also doesn't have the second line preview that you mentioned, but I
thought it might be helpful to show another way to accomplish the period
expansion.
I have a hunch that the complete command might be able to do what is needed,
but I haven't looked into it.
> On Oct 7, 2015, at 05:47, Jakob Pfender <jpfen...@zedat.fu-berlin.de> wrote:
>
> 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
> Fish-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fish-users
------------------------------------------------------------------------------
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
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users