Far and Bash

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

Far and Bash

Postby kariem » Tue 17 Mar, 2015 11:48

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: 3473
Joined: Wed 16 Mar, 2005 11:01
Been thanked: 1 time

Far and Bash

Postby Skirda » Tue 17 Mar, 2015 11:59

...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

Postby kariem » Tue 17 Mar, 2015 12:30

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

Postby serwusek » Thu 11 Jun, 2015 11:57

everything is good if it works

gene.pavlovsky
Posts: 157
Joined: Tue 11 Aug, 2015 16:53
Has thanked: 11 times

Far and Bash

Postby gene.pavlovsky » Sun 17 Apr, 2016 18:59

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: 157
Joined: Tue 11 Aug, 2015 16:53
Has thanked: 11 times

Far and Bash

Postby gene.pavlovsky » Sun 24 Apr, 2016 22:33

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: gene.pavlovsky @ Подружить Far и bash (Cygwin и другие)


Return to “General Discussions”

Who is online

Users browsing this forum: No registered users and 2 guests