Effortlessly navigate between projects with a single command.
-
Clone this repository into
$ZSH_CUSTOM/plugins
(by default~/.oh-my-zsh/custom/plugins
)git clone https://github.com/amerryma/switch-craft ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/switch-craft
-
Add the plugin to the list of plugins for Oh My Zsh to load (inside
~/.zshrc
):plugins=( # other plugins... switch-craft )
-
Start a new terminal session.
The arguments are positional. Use quotes if you need to include spaces. If you need to skip an argument, use "false".
alias cdp='switch_craft <project-display-name> <project-name> <kubectx> <gcloud> <enable-venv> <aws> <azure>'
To switch the default project dir of ~/Projects
, you can set the SWITCH_CRAFT_PROJECTS_DIR
environment variable.
export SWITCH_CRAFT_PROJECTS_DIR=~/my-projects
# or per alias
alias cdp='SWITCH_CRAFT_PROJECTS_DIR=~/my-projects switch_craft <..args>'
This is the name that will be displayed in the prompt. It can be anything you want.
This is the name of the directory that contains the project. It is relative to the SWITCH_CRAFT_PROJECTS_DIR
environment variable.
If you have kubectx installed, you can set the third argument to the name of the context you want to switch to a context name. You can list the available contexts with:
kubectx
If you have gcloud installed, you can set the fourth argument to the name of the gcloud configuration you want to switch to. You can list the available configurations with:
gcloud config configurations list
If you have a virtualenv in your project, you can set the fifth argument to the relative path within the projects dir to automatically activate the virtualenv that is a sibling of the current project. This could be useful for running python applications while in a different directory.
This requires the zsh plugin called autoswitch_virtualenv
which is
found here.
If you have aws installed, you can set the sixth argument to the name of the aws profile you want to switch to. You can list the available profiles with:
aws configure list-profiles
If you have az installed, you can set the seventh argument to the name of the azure profile you want to switch to. You can list the available profiles with:
az account list --output table
For more fun, you can install figlet and lolcat
You will need to install JS Stick Letters
font.
sudo curl -o /usr/share/figlet/JS\ Stick\ Letters.flf https://raw.githubusercontent.com/xero/figlet-fonts/master/JS%20Stick%20Letters.flf
This plugin works well with the Spaceship Prompt as it shows the different components in the prompt.