82bd622643129f01d95b3d77bb4c3f4927a9d28a
[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
12 set -e
13 set -u
14
15 # Get arch envs, etc
16 my_url="https://rootprojects.org/pathman/dist/$(uname -s)/$(uname -m)/pathman"
17 curl -fL "$my_url" -o pathman
18 echo ""
19 # Make executable
20 chmod +x ./pathman
21 # Move to ~/.local/bin
22 mkdir -p ~/.local/bin
23 mv ./pathman ~/.local/bin
24
25 # Test if in PATH
26 set +e
27 my_pathman=$(command -v pathman)
28 set -e
29 if [ -n "$my_pathman" ]; then
30         if [ "$my_pathman" != "$HOME/.local/bin/pathman" ]; then
31                 echo "a pathman installation (which make take precedence) exists at:"
32                 echo "    $my_pathman"
33                 echo ""
34         fi
35 fi
36
37 # add to ~/.local/bin to PATH even if pathman is elsewhere
38 # TODO pathman needs silent option and debug output (quiet "already exists" output)
39 ~/.local/bin/pathman add ~/.local/bin # > /dev/null 2> /dev/null
40 # TODO inform user to add to path, apart from pathman?