Skip to main content

Switch environment context easily in the shell

Project description

Swytchit

Context switching made easy for shell geeks

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 python3.11
python3.11 -m pip 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

Icon by Flaticon

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.0.tar.gz (2.7 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.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: swytchit-1.0.0.tar.gz
  • Upload date:
  • Size: 2.7 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.0.tar.gz
Algorithm Hash digest
SHA256 32fae1c5bcf25cc31699214f6c3072f769dad4e644d9c4a4ffe84bd58ba8f97c
MD5 31e4824c43bb505eb617a328622fc073
BLAKE2b-256 e5cd8def2fe2e51740c5b4ecc585f5c57ba52a895f5ab30d1e7817c64f9c17f7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swytchit-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ecbc0a23c1354ae6cfb0ae10fc77858b769057955035f6f7408c938f86c43b0
MD5 ef32e91367dfc61ce72937f62a108ec2
BLAKE2b-256 4e7bf31a7e435e2af3d6868eb527c8d823d3113fee8497f317fff9c7798204d2

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