I'm currently trying to run the
atom editor
in the bash
shell, from the fish
shell. It's important that I run atom
in bash
because of how ide-haskell handles ghc-mod
path resolution, and a few other standardization issues.
Here is how I was going at it:
#~/.config/fish/config.fish
function start-atom
bash $HOME/lib/atom/bin/Atom/atom $argv
end
However, when I try running start-atom
from fish
, I get the following error:
/home/athan/lib/atom/bin/Atom/atom: /home/athan/lib/atom/bin/Atom/atom: cannot execute binary file
Even though I know this file is correct and executable. Any ideas? Thank you!
Regular bash scripts can be used in fish shell just as scripts written in any language with proper shebang or explicitly using the interpreter (i.e. using bash script.sh ). However, many utilities, such as virtualenv, modify the shell environment and need to be sourced, and therefore cannot be used in fish.
Shells like fish are used by giving them commands. Every fish command follows the same simple syntax. A command is executed by writing the name of the command followed by any arguments. This calls the echo command.
A bash function is a method used in shell scripts to group reusable code blocks. This feature is available for most programming languages, known under different names such as procedures, methods, or subroutines.
Fish is a fully-equipped command line shell (like bash or zsh) that is smart and user-friendly. Fish supports powerful features like syntax highlighting, autosuggestions, and tab completions that just work, with nothing to learn or configure.
When you run bash file_name
it means you're trying to run file_name
as a bash script.
Try this instead:
bash -c '$HOME/lib/atom/bin/Atom/atom "$@"' dummy $argv
The -c
means "run this command with bash" instead of "run this script with bash".
As Charles pointed out in the comments, we have to do a bit of tweaking to pass the parameters to the command. We pass them to bash
which will use them as positional parameters inside of the supplied command, hence the $@
.
should be: bash -c '$HOME/lib/atom/bin/Atom/atom "$@"' _ $argv
The underscore will become bash's $0
A demo:
$ function test_bash_args
bash -c 'printf "%s\n" "$@"' _ $argv
end
$ test_bash_args one two three
one
two
three
If you need that bash session to load your configs, make it a login shell.
So, bottom line: ~/.config/fish/functions/start-atom.fish
function start-atom
bash -l -c '$HOME/lib/atom/bin/Atom/atom "$@"' _ $argv
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With