Skip to main content

Switch environment context easily in the shell

Project description

Swytchit

Switch environment context easily in the shell

Usage

sw your/project/directory
  • Performs a cd operation to the project
  • Starts a subshell
  • Within the subshell, runs source on .swytchitrc.sh files in the project directory and any ancestor directories

Use the exit command when done with the project to exit the subshell and clear the environment.

Note that .swytchitrc.sh can support any source operation, including:

  • Set environment variables
  • Define aliases
  • Define functions

Why?

  • Easily switch virtual environments for scripting languages (Python, Ruby, etc)
  • Easily populate project-specific environment variables and aliases
  • Use with the op CLI from 1Password to keep project-specific secrets in memory

Installation (MacOS)

brew install pipx
pipx install swytchit

Also do a profile/rc song and dance something like this:

echo 'if [[ -n $SWYTCHITRC ]]; then source $SWYTCHITRC; fi' >> $ZDOTDIR/.zshrc
source $ZDOTDIR/.zshrc

(use e.g. .profile or .bashrc if not on zsh)

Rules

  • Only works in TTY shell (no piping)
  • Only works for a descendent of user's home directory
  • Resolves symlinks first

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swytchit-1.0.1.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swytchit-1.0.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file swytchit-1.0.1.tar.gz.

File metadata

  • Download URL: swytchit-1.0.1.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for swytchit-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e19400b036fe35affa7c49ee6f029652b92f113548dcc022a85f95e0f7690a7d
MD5 496e94e2127383fd9e6bb2829915cc3b
BLAKE2b-256 7ab4de0cb2926556479da8bbe4081ac99675b5e822d7bc95f3a6590cdc5d89d0

See more details on using hashes here.

File details

Details for the file swytchit-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: swytchit-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for swytchit-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 353c89e912176d1161d818a3bdb59b30a3afbfe02be2772269c2528b05096b31
MD5 30cd57bd5392f04bf210fc589ea6b239
BLAKE2b-256 2b8fd32027d394b47912493a97c9abf0184966922475adb7b6dc4defcddce7cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page