burn the logs and use 'install.bash'
[webi-installers/.git] / pathman / install.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 #   Manages PATH on various OSes and shells
8 #     - Mac, Windows, Linux
9 #     - Bash, Zsh, Fish
10 #     - Command, Powershell
11 # examples: |
12 #   ```bash
13 #   pathman add ~/.local/bin
14 #   ```
15 #   <br/>
16 #
17 #   ```bash
18 #   pathman remove ~/.local/bin
19 #   ```
20 #   <br/>
21 #
22 #   ```bash
23 #   pathman list
24 #   ```
25
26
27 set -e
28 set -u
29
30 # Test if in PATH
31 set +e
32 my_pathman=$(command -v pathman)
33 set -e
34 if [ -n "$my_pathman" ]; then
35     # TODO test pathman version
36     # if [ "$WEBI_VERSION" == "$(pathman version | cut -d ' ' -f2)" ]; then
37         if [ "$my_pathman" != "$HOME/.local/bin/pathman" ]; then
38                 echo "a pathman installation (which make take precedence) exists at:"
39                 echo "    $my_pathman"
40                 echo ""
41         fi
42     echo "pathman already installed"
43     exit 0
44 fi
45
46 # TODO use webi_download via releases.js
47 webi_download "https://rootprojects.org/pathman/dist/$(uname -s)/$(uname -m)/pathman" "$HOME/.local/bin/pathman"
48
49 # TODO use webi_extract
50 chmod +x "$HOME/.local/bin/pathman"
51
52 # add to ~/.local/bin to PATH even if pathman is elsewhere
53 # TODO pathman needs silent option and debug output (quiet "already exists" output)
54 "$HOME/.local/bin/pathman" add ~/.local/bin # > /dev/null 2> /dev/null
55 # TODO inform user to add to path, apart from pathman?