Axel Liljencrantz wrote: >> This makes mc left you on the last directory you were navigating >> inside mc when it exits, pretty useful. All the magic is done by the >> '-P' switch. >> ... >> so in fish I do this in my config.fish (which *is* being sourced): >> >> function mc >> set mctmpfile (tempfile) >> /usr/bin/mc -P $mctmpfile >> cd (cat $mctmpfile) >> rm -f $mctmpfile >> set mctmpfile >> end >> >> But it doesn't work. > > I suspect that the empty file problem you're seeing is actually a > regession bug in fish. Specifically, I belive the file in question > does contain the file name, but does not end with a newline, and that > the fish prompt 'swallows' the output. You can test this theory by > calling echo after cat-ing the file. The next fish release will fix > this problem.
Indeed, that was one of the problems. And thanks for taking the issue into consideration for the next release. > The following script seems to work correctly for me, though the choice > of filename leaves something to be desired: > > function mc > set tmpfile ~/ggg > command mc -P $tmpfile > cd (cat $tmpfile) > rm $tmpfile > end fish swallowing the cat of a newlineless line was an issue, but not the actual problem, but it was a problem that complicated for me the finding of a solution. The problem was using the command 'tempfile' (it comes in debianutils package on my gentoo). mc creates the file given on the -P switch upon exit, if the file exists, it silently fails to create it and left you in the directory where you were before issuing mc. So the filename given to the -P switch must be a nonexistent file. I modified your version of the function to this: set tmpfile /tmp/mcpwd-(random) If not using 'random' or using the same file name, the -P switch stops working as soon as you start mc twice (or more). It only work the first time you exit mc. Though 'random' works it annoys me that it doesn't assure the uniqueness of the filename. I know it will be very difficult to get 'random' give two equal numbers, but I would be more comfortable knowing it's *impossible*. > Hope this helps! Sure it did, thank you :) Would you consider adding a new command to fish that gives a unique file name on a given directory? I found myself in the past several times with this necessity and I think it would be pretty useful to have it in the shell itself. Also it will not bloat fish since you'll only need to wrap a call to tempnam(3) in the command. I know I could do a simple C program, but that would be extern, I really think it should go into fish, however I may be overlooking a simpler solution made with what is already provided, so I wanna hear you opinions. -- Fernando Canizo - http://muriandre.homelinux.org/~conan/ ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users