{"id":13862990,"url":"https://github.com/benvan/sandboxd","last_synced_at":"2025-04-11T03:13:07.932Z","repository":{"id":46193065,"uuid":"60921424","full_name":"benvan/sandboxd","owner":"benvan","description":"speeds up your bashrc by running (slow) setup commands on the fly","archived":false,"fork":false,"pushed_at":"2021-11-08T12:27:38.000Z","size":22,"stargazers_count":238,"open_issues_count":2,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-11T03:13:02.168Z","etag":null,"topics":[],"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/benvan.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}},"created_at":"2016-06-11T18:18:18.000Z","updated_at":"2025-03-13T11:45:50.000Z","dependencies_parsed_at":"2022-09-22T08:43:19.092Z","dependency_job_id":null,"html_url":"https://github.com/benvan/sandboxd","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benvan%2Fsandboxd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benvan%2Fsandboxd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benvan%2Fsandboxd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benvan%2Fsandboxd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benvan","download_url":"https://codeload.github.com/benvan/sandboxd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248333603,"owners_count":21086200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-08-05T06:01:59.046Z","updated_at":"2025-04-11T03:13:07.906Z","avatar_url":"https://github.com/benvan.png","language":"Shell","readme":"# sandboxd\nSpeed up your bashrc / zshrc: avoids running (slow) setup commands until you actually need them.\n\n# Why?\nHaving installed `nvm`, `rvm`, `virtualenvwrapper` and other similar [gubbins](http://www.urbandictionary.com/define.php?term=gubbins) over time, my shell starts horrifically slowly. By running these setup scripts on-demand, my time-to-first-prompt is nice and fast again. On top of this, I rarely need all of these tools enabled at the same time...\n\n# How?\nsandboxd creates a placeholder shell function for each command you specify (e.g. `rvm`). When this command gets run for the first time, the following happens:\n- the `cmd` placeholder function (plus all associated placeholders) gets removed\n- the setup you have associated with `cmd` gets run,\n- `cmd` gets run with the original arguments\n\n# Usage\nTo 'sandbox' a setup, wrap it in a function named `sandbox_init_[name]`:\n\n```bash\n# in ~/.bashrc / your shell rc file\nsource /path/to/sandboxd\n\n\n# in ~/.sandboxrc\nsandbox_init_nvm(){\n  source $(brew --prefix nvm)/nvm.sh #long running setup command\n}\n\n# create hooks for commands 'nvm', 'node' and 'nodemon'\nsandbox_hook nvm node\nsandbox_hook nvm nodemon\n# this one not needed: it's created automatically based on the sandbox name\n# sandbox_hook nvm nvm\n```\n\nThe sandbox setup gets run _once_, when either `nvm`, `nodemon` or `node` is used for the first time:\n\n```bash\n[20:45:44 ~] echo 'console.log(\"hi\")' | node\nsandboxing nvm ...\nhi\n[20:45:53 ~] echo 'console.log(\"hi\")' | node\nhi\n```\n\n## Manually calling the sandbox command\nTo manually run a specific sandbox setup, run `sandbox [name]`\n\nThis might be useful if you want to run a sandbox that doesn't have an associated command, or to create \"feature flags\" in your rc file:\n\n```bash\n#uncomment to enable features\n\n# sandbox virtualenv\nsandbox rvm\nsandbox nvm\n```\n\n# Shims\nTools like [pyenv](https://github.com/pyenv/pyenv), [rbenv](https://github.com/rbenv/rbenv), [nodenv](https://github.com/nodenv/nodenv) etc use the concept of ['shims'](https://github.com/pyenv/pyenv#understanding-shims), which are helper scripts created when installed packages create command line utilities (e.g. installing the AWS CLI via Pip creates the `aws` command). To make it easy for sandboxd to lazy-load these environments when any of these 'shims' are called, use the function `sandbox_hook_shims {\u003cname\u003e} [\u003cdir\u003e]`. See [sandboxrc.example.pyenv](sandboxrc.example.pyenv) for more information.\n\nExample:\nShims created under `~/.pyenv/shims/`\n```bash\n$ ls -l ~/.pyenv/shims\nansible\nansible-config\naws\nflask\n[...]\n```\n\nTo automatically add them all as a sandboxd `hook`, simply add the following to `.sandboxrc`:\n```bash\n# in ~/.sandboxrc\n\nsandbox_init_pyenv() {\n  export PYENV_ROOT=\"$HOME/.pyenv\"\n  export PATH=\"$PYENV_ROOT/bin:$PATH\"\n  export VIRTUAL_ENV_DISABLE_PROMPT=1\n  eval \"$(pyenv init -)\"\n  eval \"$(pyenv virtualenv-init -)\"\n}\n\nsandbox_hook_shims pyenv\n```\n\nHere, the `pyenv` argument of `sandbox_hook_shims` matches the function name defined above (`sandbox_init_pyenv`).\n`sandbox_hook_shims` assumes the shim directory to be `~/.\u003cname\u003e/shims` where `\u003cname\u003e` is the first argument. If the diretory is different, pass it as an argument:\n\n```bash\nsandbox_hook_shims pyenv /path/to/shim/directory\n```\n\n## sandboxrc configuration file\nThe location of the configuration file depends on the environment's configuration. The file is searched in the following order:\n\n1. `$SANDBOXRC` -  if it is set. This has highest precedence. Thus you can set this to override to custom location.\n1. `$XDG_CONFIG_HOME/sandboxd/sandboxrc` - if the directory `sandboxd/` exist. Note that `$XDG_CONFIG_HOME` defaults to `$HOME/.config`\n1. `$HOME/.sandboxrc` - fall back to old default location.\n","funding_links":[],"categories":["Plugins","Shell"],"sub_categories":["ZSH on Windows"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenvan%2Fsandboxd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenvan%2Fsandboxd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenvan%2Fsandboxd/lists"}