alt the version switcher
alt is a command line utility that lets you switch between different versions
of commands based on your current directory.
Why?
As developers, we work with a large number of tools. When we move from codebase to codebase, those tools and their versions change. Switching between the different versions of those tools every time you change codebase is a nightmare.
This is where alt comes in. It will automatically switch the version of
commands when you move to a different codebase.
There are other tools out there that solve this problem. alt distinguish
itself in a few ways:
- tool / language agnostic: Some version switching tools only work with a
specific tool or programming language.
altis generic. It works for any command. - no shell pollution: Most version switching tools hook themselves into
your shell. This can slow down your shell's start time.
altdoes not hook into your shell. You can use it without slowing down your shell start time. - only version switching: Unlike other tools,
altdoes not take responsibility for installing different versions of commands or managing their dependencies. How you install different versions of commands is entirely up to you.
Installation
-
Install the
altbinary.curl -sL https://github.com/dotboris/alt/raw/master/install.sh | bash -s -
Add the
altshims directory to the top of yourPATH. This letsaltchange command versions.For BASH:
echo 'export PATH="$HOME/.local/alt/shims:$PATH"' >> ~/.bashrc export PATH="$HOME/.local/alt/shims:$PATH"
For ZSH:
echo 'export PATH="$HOME/.local/alt/shims:$PATH"' >> ~/.zshrc export PATH="$HOME/.local/alt/shims:$PATH"
For FISH:
echo 'set -x PATH "$HOME/.local/alt/shims" $PATH' >> ~/.config/fish/config.fish set -x PATH "$HOME/.local/alt/shims" $PATH
-
(Optional) Add
.alt.tomlto your global gitignore file.During it's operation,
altputs a file named.alt.tomlin the current directory. These files don't belong in git repositories. To avoid getting those files all over your git repositories, you can add them to a global gitignore file.If you don't know how to create a global gitignore file, see: https://help.github.com/articles/ignoring-files/#create-a-global-gitignore
Usage
Using alt is done in two steps:
- First, you tell
altabout the different versions of commands installed on your system. - Second, you tell
altwhat version of your commands to use in a given directory.
Define command versions
alt can automatically scan your system to find different version of a command.
This can be done with the alt scan command:
alt scan some-commandThis will bring up a menu that lets you choose all the versions of the given
command that you want to use with alt.
- ↑ / ↓ or j / k: Move cursor
- Space: Make version available to
alt - Enter: Confirm and save selection
If alt is not able to find a version of a command automatically for you, you
can always define the command version by hand.
This can be done with the alt def command:
alt def some-command version-name /path/to/command/binSwitch command version
Remember that alt decides what version of a command to use based on the
current directory. When you select a command version, it's for the current
directory.
You can tell alt to use a specific version of a command in the current
directory with the alt use command:
alt use some-commandThis will bring up a menu that lets you choose the version of the specified command that you want to use.
- ↑ / ↓ or j / k: Move cursor
- Enter: Select version to use
If menus aren't your cup of tea, you can specify the version on the command line:
alt use some-command version-nameShow known commands & used versions
alt showThe above command will show you:
- All commands
altknows about - The versions of those commands available
- The versions being used in the current directory
Development
Setup
See: https://doc.rust-lang.org/book/second-edition/ch01-01-installation.html
Run
cargo run ...Test
cargo test