Far and Bash

You want to talk about Far Manager, but don't know where to turn?
Post Reply
kariem
Posts: 7
Joined: Tue 18 Nov, 2014 07:08

Far and Bash

Post by kariem »

Is it possible to have bash as the default shell used by far instead of cmd? I am talking about the command line at the bottom.
User avatar
Skirda
Posts: 3475
Joined: Wed 16 Mar, 2005 11:01
Been thanked: 8 times

Far and Bash

Post by Skirda »

...need change the module, responsible for the execution of commands.
All the source code is configured to use cmd.exe (and analogues).
It is also necessary to remember about the characters '\' and '/' in the path of the file name, etc.
We are the Borg. You will be assimilated.
So Say We All!
kariem
Posts: 7
Joined: Tue 18 Nov, 2014 07:08

Far and Bash

Post by kariem »

I see. It would be very nice to have the shell abstracted away and make it configurable from the options to use other shells like bash and powershell. For the time being I am using:

Code: Select all

bash -c "[COMMANDS]"
serwusek
Posts: 3
Joined: Thu 11 Jun, 2015 11:41

Far and Bash

Post by serwusek »

everything is good if it works
gene.pavlovsky
Posts: 173
Joined: Tue 16 Feb, 2010 17:55
Location: Luxembourg
Has thanked: 13 times
Been thanked: 9 times
Contact:

Far and Bash

Post by gene.pavlovsky »

I would also like to use bash very much. The question here is:
1) Simplest addition - add an extra hotkey (e.g. AltEnter) which would execute the current command line using a specified shell. This can be already implemented quite easily as a macro (I think).
2) Far takes care of command entry. When pressing enter to execute command, Far can check if the command is actually an internal Far command (e.g. lm:load, far:config etc.), if so - handle it appropriately. If the command is not an internal Far command, execute it using an arbitrary configured shell (e.g. "bash -c '$CMD'"). I guess this is easier to implement, but doesn't give bash's completion or hotkeys.
3) Completely replace the command entry with bash, I can see some extra difficulties in implementing this. It would give bash completion and hotkeys, but some bash's hotkeys already have some usage in Far (e.g. Tab!), how to deal with that? Then, how can Far intercept it's internal commands which shouldn't be executed by bash, but by Far itself (lm:load, far:config etc.)? There probably will be some extra difficulties to use some Windows-specific commands - e.g. bash doesn't understand '\' as path delimiter, so wouldn't offer completion if paths are typed with '\', also '\' would have to be quoted or escaped since otherwise bash would treat them as escape sequences; but '\' would have to be used from time to time, since some Windows tools support only '\' paths. This could be solved with using "$(cygpath -w /some/path)" whenever a Windows path is desired (assuming bash comes from Cygwin), but this might be not that convenient.
gene.pavlovsky
Posts: 173
Joined: Tue 16 Feb, 2010 17:55
Location: Luxembourg
Has thanked: 13 times
Been thanked: 9 times
Contact:

Far and Bash

Post by gene.pavlovsky »

NOTE: I'm using Cygwin, this might work with Git bash or some other ones but you might have to take more care of pathname translations.
I got some success on the topic, using the built-in features.

Save this script as bashcmd.sh somewhere:


If you didn't do it already, configure your system to execute `.sh` files using `bash` (google `cygwin bash assoc ftype` - I didn't have to use '-li' option to bash like some people had).
Execute `set comspec=C:\path\to\bashcmd.sh` in Far .
Try it out `for i in {01..10}; do echo $i; done`
If there are any problems, `set BASHCMD_DEBUG=1` and the wrapper will print the original command from Far and the prepared command before evaluating it.
Note that Cygwin does automatically translate windows-style path and can use both `/` and `\`, but if possible, avoid `\` as they should be quoted or escaped to avoid processing by bash.

Thread on Russian forum: http://forum.farmanager.com/viewtopic.p ... 16#p137316
Post Reply

Return to “General Discussions”