{"id":29554352,"url":"https://github.com/alberto-lazari/contx","last_synced_at":"2026-05-03T23:36:28.528Z","repository":{"id":304391740,"uuid":"957218713","full_name":"alberto-lazari/contx","owner":"alberto-lazari","description":"Flexible shell environments manager","archived":false,"fork":false,"pushed_at":"2025-09-20T07:50:30.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-20T09:26:41.714Z","etag":null,"topics":["automation","bash","config","configuration","environment","shell","venv","virtual-environment","zsh"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alberto-lazari.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-29T20:43:50.000Z","updated_at":"2025-09-20T07:50:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"98e1823f-573f-47c5-aa79-e13386293821","html_url":"https://github.com/alberto-lazari/contx","commit_stats":null,"previous_names":["alberto-lazari/contx"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alberto-lazari/contx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alberto-lazari%2Fcontx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alberto-lazari%2Fcontx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alberto-lazari%2Fcontx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alberto-lazari%2Fcontx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alberto-lazari","download_url":"https://codeload.github.com/alberto-lazari/contx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alberto-lazari%2Fcontx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32589262,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"ssl_error","status_checked_at":"2026-05-03T22:09:10.534Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","bash","config","configuration","environment","shell","venv","virtual-environment","zsh"],"created_at":"2025-07-18T07:09:34.317Z","updated_at":"2026-05-03T23:36:28.523Z","avatar_url":"https://github.com/alberto-lazari.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Contx\n\n_A flexible virtual environment manager for your shell_\n\n`contx` is a simple CLI tool that provides virtual environments (contexts) for interactive shells. \\\nIt can be viewed as a very simple virtual layer built on top of the default shell experience,\nmeant to enhance and simplify its scripting capabilities. \\\nIt is inspired by tools like direnv,\nthat provide a mechanism to source custom scripts based on the current directory.\n\n\n## Project-based Functions\n\nThe main use-case is defining custom shell functions and behaviors that can be automatically activated for specific contexts,\nlike custom aliases or functions that only make sense for a very specific set of projects. \\\nBy defining them in the scope of a context you avoid cluttering your system environment,\nalso allowing context-based namespaces:\nyou can define multiple generic `build` functions,\nthat hide some complexity of building a specific project,\nwithout worrying of clashing with other `build` function defined elsewhere.\n\n## Automation\n\n`contx` can also be used to automate common initialization tasks,\nlike navigating to a project directory,\nopening a text editor or a related GUI program,\nstarting build jobs in the background, etc... \\\nThese are all very simple tasks that I just wanted to automate (or simplify),\nafter having manually done them countless times.\n\n## How Does It Work?\n\n### Subshell Instance\nIt simply spawns a shell instance, running a custom init script on top of what you already have. \\\nThe init scripts are essentially what defines your context,\nyou can run almost anything you want inside of them. \\\nThey can be placed in a centralized filesystem structure or in relevant directories themselves.\n\nBy living inside a subshell, the environment can be discarded by simply exiting the shell. \\\nWith this mechanism you can easily enter and exit environments without leaving side effects on you current shell.\n\n### Unnamed/Named Contexts\nBy creating them in a `.contx/` directory they define an unnamed context,\nthat can be run by specifying the directory: `contx /path/to/dir`\n\nYou can also define named contexts, that can be invoked anywhere, like with `contx MyProj`.\nYou can use it to define contexts which are not necessarily tied to a specific directory,\nbut just provides functions or common environments.\nI personally use them to define contexts that I want to version in a repository,\nso that I don't include `.contx/` dirs in projects I share with others.\n\n### Examples\n\nYou can look at my [dotfiles repo](https://github.com/alberto-lazari/.dotfiles/tree/main/contx/contexts) for some contexts I'm using.\n\n## Why Not Using Alternatives?\n\nI'm probably not aware of all possible alternatives out there,\nbut I had reasons not to use the most popular ones:\n- direnv, the main inspiration: it uses an implicit approach, where you navigate to a directory and it loads all relevant scripts. \\\n  I wanted a cleaner, declarative approach, where you explicitly tell which environment you want to use and when.\n  I'm not a huge fan of the allow security system in general too,\n  it contributes to make the system deviate from the standard shell experience.\n- tmux: cool, but I never used it.\n  It seems like wanting to re-create window management in the terminal,\n  just like emacs tries to replace your OS.\n  It feels cleaner to just use my WM and spawn multiple terminal windows.\n  I also can't stand the fact that I would need to invent another layer of keyboard shortcuts that would not collide with vim and my WM.\n- venv/rvm/nvm/...: those are language-specific systems,\n  mostly related to package management.\n  I wanted a scriptable, general-purpose environment manager.\n- just/task/make/...: those are cool,\n  but meant for tasks and I want to automate every aspect of my shell interactions,\n  like opening a project I'm working on, along with relevant external tools.\n- nix-shell: looks very cool, but I never found time to look into it.\n  It also looks like a configuration manager rather than a system that would allow me to run simple scripts.\n  It's probably too powerful for such trivial purposes.\n- Containers (docker/podman/...): absolutely overkill.\n  I'm not interested in isolation or reproducibility.\n  It would also bring a huge overhead with it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falberto-lazari%2Fcontx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falberto-lazari%2Fcontx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falberto-lazari%2Fcontx/lists"}