User: Password:
|
|
Subscribe / Log in / New account

Fish - filename transformation

Fish - filename transformation

Posted May 28, 2005 15:25 UTC (Sat) by pason.fazon (guest, #30195)
Parent article: Fish - The friendly interactive shell

Is there any possibility in fish easily transform/switch filename - you have written on command line - between relative and absolute form of a path if you placed cursor in the filename? The transformation to absolute form is clear, transformation from absolute to relative form could use the current directory as a referential point for the transformation. There are many other imaginable referential points (history of directories, ...), a current directory is propably the most prominent candidate for me.
I didn't discover this useful capability in any other shell (including zsh).


(Log in to post comments)

Fish - filename transformation

Posted May 30, 2005 9:22 UTC (Mon) by liljencrantz (guest, #28458) [Link]

This type of feature is the kind of thing that should be possible to do yourself with very little effort. There is a world of difference between something configurable and something extensible. While there are virtually no configuration options in fish, there is a rudimentary framework for extending the shell using simple shellscripts. As this framework improves, I hope people will start hacking shellscripts that extend fish and make it cooler.

You can already bind arbitrary shell commands to a keyboard shortcuts, and get the value of the token under the cursor. Writing a bit of shellscript to change from a relative to an absolute filename is pretty easy. The only part that is missing is changing the token under the cursor. You can currently only set or append to the commandline. I was already planning on adding support for changing the current token, in order to move more and more of the fish implementation into shellscript.

So in the near future, the following should do what you want:

1). Create a file called .fish_inputrc in your home directory containing the lines

$include /etc/fish_inputrc
"\M-a": evaluate-command make_absolute_path

2). Create a file called .fish in your home directory containing something like this:

function make_absolute_path
set result $PWD/(commandline --current-token)
commandline --current-token $result
end

Obviously, the relative to absolute convertion is in much need of improvement, but otherwise, that should work as soon as I add the required functionality to the commandline builtin.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds