Add a bash script to path
bash, linux, path, shell
Solution
Try this:
- Save the script as `apt-proxy` (without the `.sh` extension) in some directory, like `~/bin`.
- Add `~/bin` to your `PATH`, typing `export PATH=$PATH:~/bin`
- If you need it permanently, add that last line in your `~/.bashrc`. If you're using `zsh`, then add it to `~/.zshrc` instead.
- Then you can just run `apt-proxy` with your arguments and it will run anywhere.
Note that if you `export` the PATH variable in a specific window it won't update in other bash instances.
Problem
I want to add a small script to the linux PATH so I don't have to actually run it where it's physically placed on disk. The script is quite simple is about giving apt-get access through a proxy I made it like this: ``` #!/bin/bash array=( $@ ) len=${#array[@]} _args=${array[@]:1:$len} sudo http_proxy="http://user:password@server:port" apt-get $_args ``` Then I saved this as apt-proxy.sh, set it to +x (chmod) and everything is working fine when I am in the directory where this file is placed. My question is : how to add this apt-proxy to PATH so I can actually call it as if it where the real apt-get ? [from anywhere] Looking for command line only solutions, if you know how to do by GUI its nice, but not what I am looking for.