add examples
[webi-installers/.git] / pathman / pathman.bash
1 #!/bin/bash
2
3 # title: Pathman
4 # homepage: https://git.rootprojects.org/root/pathman
5 # tagline: cross-platform PATH management for bash, zsh, fish, cmd.exe, and PowerShell
6 # description: |
7 #   Works with
8 #   - Mac, Windows, Linux
9 #   - Bash, Zsh, Fish
10 #   - Command, Powershell
11 # examples: |
12 #   ```bash
13 #   pathman add ~/.local/bin
14 #   ```
15 #   <br/>
16 #   ```bash
17 #   pathman remove ~/.local/bin
18 #   ```
19 #   <br/>
20 #   ```bash
21 #   pathman list
22 #   ```
23
24
25 set -e
26 set -u
27
28 # Get arch envs, etc
29 my_url="https://rootprojects.org/pathman/dist/$(uname -s)/$(uname -m)/pathman"
30 curl -fL "$my_url" -o pathman
31 echo ""
32 # Make executable
33 chmod +x ./pathman
34 # Move to ~/.local/bin
35 mkdir -p ~/.local/bin
36 mv ./pathman ~/.local/bin
37
38 # Test if in PATH
39 set +e
40 my_pathman=$(command -v pathman)
41 set -e
42 if [ -n "$my_pathman" ]; then
43         if [ "$my_pathman" != "$HOME/.local/bin/pathman" ]; then
44                 echo "a pathman installation (which make take precedence) exists at:"
45                 echo "    $my_pathman"
46                 echo ""
47         fi
48 fi
49
50 # add to ~/.local/bin to PATH even if pathman is elsewhere
51 # TODO pathman needs silent option and debug output (quiet "already exists" output)
52 ~/.local/bin/pathman add ~/.local/bin # > /dev/null 2> /dev/null
53 # TODO inform user to add to path, apart from pathman?