0

just trying out ubuntu, and installed a node/npm CLI application where we can run the command in the terminal. That command/tool requires us to specify the browser e cutable path every time when we run it.

think if we can add its path in the .bashrc, so we can just run it without adding it.

Now:

commandTesting https://www.wikipedia.org
browserExecutablePath /usr/bin/google-chrome

would like it to be:

commandTesting https://www.wikipedia.org

Already try:

export PATH=$PATH:/usr/bin/google-chrome

Doesn't help. Please advise if we can do something like this in ubuntu.

1 Answer 1

0

There are different ways to Rome, but the preferred, conventional way is to add an executable to your search PATH, rather than adding a directory to the PATH.

Imagine, it would become very unwieldy if you decided to add a directory to your search path for every new executable you install.

To add the executable to your existing search PATH, there are two options.

  1. Create a symlink in a directory that exists in your search path
  2. Create a wrapper script in a directory that exists in your search path.

Such symlink or script should be placed in ~/.local/bin if only the current user should be able to run the command, or in /usr/local/bin if the command should be available to any user.

  • To create a symlink: ln -s /path/to/executable /usr/local/bin/mycustombrowser
  • A wrapper script, e.g. named /usr/local/bin/mycustombrowser at minimum launches the actual executable using the full path name, but could also change directories, set environment variables, etc., e.g.:
    #!/usr/bin/env sh
    VARIABLE="Some value"
    cd /some/path
    /path/to/executable

To be executable, the executablele bit of the script file must be set.

Do not put such executable in /usr/bin or other directories: these are managed by your package management system. The directories under local are conventionally designed for your manually installed applications, and these actually will everride similarly named executables in the other directories in the PATH.

Then, if the need is more temporary, one could also create an alias:

alias mycustombrowser='/path/to/executable'

Also this way, an executable can be launched simply by typing a name instead of the full path. An alias can be added to .bashrc to be available automatically for the current user.

If, after all this, there still is a need to change the actual PATH, then here is how to do that.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .