https://github.com/fedragon/cuttlefish
Switch environment according to current working directory
https://github.com/fedragon/cuttlefish
environment fish golang shell shell-extension
Last synced: about 1 month ago
JSON representation
Switch environment according to current working directory
- Host: GitHub
- URL: https://github.com/fedragon/cuttlefish
- Owner: fedragon
- License: mit
- Created: 2020-06-07T12:25:41.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2022-06-23T14:58:17.000Z (about 4 years ago)
- Last Synced: 2025-04-10T16:21:57.702Z (about 1 year ago)
- Topics: environment, fish, golang, shell, shell-extension
- Language: Go
- Homepage:
- Size: 48.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cuttlefish

Switch environment according to current working directory. Heavily inspired by the amazing [direnv](https://direnv.net/), but not limited to environment variables and only targeting [fish shell](https://fishshell.com).
## Features
Configure any combination of the following in a simple YAML file:
- ssh identities
- paths (to append to `$fish_user_paths`, which then becomes a _universal_ variable)
- global (= universal) variables
- git user details (name, email address)
Whenever you visit a directory containing a `.cuttlefish.yaml` file, its configuration is applied to your environment.
**Note:** Only subdirectories of the user's home directory are scanned.
## Install
**Note:** The script installs itself in your `~/.config/fish/config.fish`: before doing so, though, it will copy the original file to `~/.config/fish/config.fish_bck` so that it can be restored for any reason (see `install` target in `Makefile` for more details).
### Option 1: Install released binaries
Grab the binaries from the [releases page](https://github.com/fedragon/cuttlefish/releases), uncompress them and run e.g.
```shell
cd cuttlefish-darwin64
make install
```
### Option 2: Build from sources
The installation requires Go 1.25+.
```shell
git clone https://github.com/fedragon/cuttlefish
cd cuttlefish
make
```
### Usage
Create a `.cuttlefish.yaml` in every directory where you want to load a different environment and ensure it is only writable by the current user (`chmod 644 .cuttlefish.yaml`).
The file should look like this:
```yaml
git_config:
name: John Doe
email: foo@bar.com
ssh_identities:
- ~/.ssh/id_rsa1
- ~/.ssh/id_rsa2
# - ...
user_paths:
- ~/Documents
- ~/Desktop
# - ...
global_variables:
FOO: bar
# x: y
# ... : ...
```
Any combination of the above fields is possible and they're all optional. A complete example is available in `examples/cuttlefish.yaml`.
### Uninstall
```shell
cd cuttlefish
make uninstall
```
## Develop
### Build
```shell
make build
```
### Test
**Note:** This requires a running Docker daemon.
```shell
make test
```
### Release
```shell
make release
```
## Credits
Cuttlefish logo made by [Freepik](http://www.freepik.com/).