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