Page 1 of 1

Far and Bash

Posted: Tue 17 Mar, 2015 11:48
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.

Far and Bash

Posted: Tue 17 Mar, 2015 11:59
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.

Far and Bash

Posted: Tue 17 Mar, 2015 12:30
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]"

Far and Bash

Posted: Thu 11 Jun, 2015 11:57
by serwusek
everything is good if it works

Far and Bash

Posted: Sun 17 Apr, 2016 18:59
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.

Far and Bash

Posted: Sun 24 Apr, 2016 22:33
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