{"id":13602801,"url":"https://github.com/mrjones2014/ctrlg","last_synced_at":"2025-04-11T13:31:30.469Z","repository":{"id":42656376,"uuid":"439434077","full_name":"mrjones2014/ctrlg","owner":"mrjones2014","description":"A command line context switcher, written in Rust :crab:","archived":true,"fork":false,"pushed_at":"2022-08-23T23:24:37.000Z","size":9059,"stargazers_count":30,"open_issues_count":7,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-07T16:04:28.369Z","etag":null,"topics":["bash","cd","cli","context-switching","fish","fuzzy-finder","fuzzy-search","productivity","rust","shell","shell-plugin","terminal","tmux","zsh"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/ctrlg","language":"Rust","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/mrjones2014.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"mrjones2014"}},"created_at":"2021-12-17T19:02:43.000Z","updated_at":"2024-08-10T16:58:11.000Z","dependencies_parsed_at":"2022-08-20T00:41:20.484Z","dependency_job_id":null,"html_url":"https://github.com/mrjones2014/ctrlg","commit_stats":null,"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrjones2014%2Fctrlg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrjones2014%2Fctrlg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrjones2014%2Fctrlg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrjones2014%2Fctrlg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrjones2014","download_url":"https://codeload.github.com/mrjones2014/ctrlg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223470264,"owners_count":17150523,"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":["bash","cd","cli","context-switching","fish","fuzzy-finder","fuzzy-search","productivity","rust","shell","shell-plugin","terminal","tmux","zsh"],"created_at":"2024-08-01T18:01:38.424Z","updated_at":"2024-11-07T06:30:21.751Z","avatar_url":"https://github.com/mrjones2014.png","language":"Rust","readme":"# ctrlg ⌨️\n\n###### Press \u003ckbd\u003ectrl\u003c/kbd\u003e + \u003ckbd\u003eg\u003c/kbd\u003e to jump between projects using a fuzzy finder\n\n![demo](https://github.com/mrjones2014/ctrlg/raw/master/demo.gif)\n\u003csup\u003eDemo is using the [tmux integration](#tmux-integration) for floating window and [lighthaus](https://github.com/mrjones2014/lighthaus.nvim) terminal theme.\u003c/sup\u003e\n\nCtrlg is a tool to quickly switch contexts to another directory, using a fuzzy finder.\nIf enabled (by setting `$CTRLG_TMUX` to `true`), `ctrlg` can `cd` all split panes in the current window of a `tmux` session\nto the selected directory. Press \u003ckbd\u003ectrl\u003c/kbd\u003e + \u003ckbd\u003eg\u003c/kbd\u003e to fuzzy find directories,\nconfigured by globbing patterns.\n\nBy default, only `~/git/*` is searched. To change this or add additional\ndirectories to search, see [configuration](#configuration).\n\n## Install\n\n### With Cargo\n\n```sh\ncargo install ctrlg\n```\n\n`cargo` can be installed via [rustup.rs](https://rustup.rs).\n\n### With Installer Script\n\nDo not run as root or with `sudo`, the script will ask for `sudo` if needed.\n\n```sh\nbash -c 'bash \u003c(curl --proto \"=https\" --tlsv1.2 -sSf https://raw.githubusercontent.com/mrjones2014/ctrlg/master/install.bash)'\n```\n\n### Manual\n\n1. Download the appropriate binary for your system from the [latest GitHub Release](https://github.com/mrjones2014/ctrlg/releases)\n1. Rename the binary `ctrlg`\n1. Make the binary executable via `chmod +x ctrlg`\n1. Put the binary anywhere on your `$PATH`, such as `/usr/local/bin/ctrlg`\n\n### Build and Install from Source\n\nRequires `cargo`:\n\n```sh\ngit clone git@github.com:mrjones2014/ctrlg.git\ncd ctrlg\ncargo install --path .\n```\n\n## Shell Plugin\n\nOnce the CLI is installed, you will need to set up the key binding depending on your shell.\nAlternatively, you can disable the default keybind by setting `$CTRLG_NOBIND` to `true`\nbefore running the init script, then set up your own keybind to call `_ctrlg_search_and_go`.\n\n### Fish\n\n```fish\necho 'ctrlg init fish | source' \u003e\u003e ~/.config/fish/config.fish\n```\n\n### Zsh\n\n```zsh\necho 'eval \"$(ctrlg init zsh)\"' \u003e\u003e ~/.zshrc\n```\n\n### Bash\n\n```bash\necho 'eval \"$(ctrlg init bash)\"' \u003e\u003e ~/.bashrc\n```\n\n## Tmux Integration\n\nTo make `ctrlg` send the `cd` command to all split panes in the current `tmux`\nwindow, set the environment variable `CTRLG_TMUX` to `true`. You can also make the fuzzy finder\nappear in a `tmux` floating window, and specify the window size, with `$CTRLG_TMUX_POPUP` and\n`$CTRLG_TMUX_POPUP_ARGS`, respectively. `$CTRLG_TMUX_POPUP_ARGS` can be any window positioning\nor sizing arguments accepted by `tmux popup`. `$CTRLG_TMUX_POPUP_ARGS` defaults to `-w 75% -h 75%`.\n\nYou can also define a hook function to send the `cd` command to additional `tmux` panes not in the\ncurrent window. The function must return a list of `tmux` pane IDs. The hook function is\n`_ctrlg_get_related_panes`.\n\n### Fish\n\n```fish\nset CTRLG_TMUX true\nset CTRLG_TMUX_POPUP true\n# IMPORTANT: quote each argument separately so that the variable is an array\nset CTRLG_TMUX_POPUP_ARGS \"-w\" \"75%\" \"-h\" \"75%\"\n```\n\n### Bash or Zsh\n\n```bash\nexport CTRLG_TMUX=true\nexport CTRLG_TMUX_POPUP=true\n# for bash and zsh, quote all arguments together\nexport CTRLG_TMUX_POPUP_ARGS=\"-w 75% -h 75%\"\n```\n\n## Key Bindings\n\n| Key Binding                              | Function                                                                                                                                                                   |\n| ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| \u003ckbd\u003eEnter\u003c/kbd\u003e                         | `cd` to the selected directory. If `$CTRLG_TMUX` is `true`, the `cd` command is sent to all split panes in the current window.                                             |\n| \u003ckbd\u003eAlt/Option\u003c/kbd\u003e + \u003ckbd\u003eEnter\u003c/kbd\u003e | `cd` to the selected directory, then open `$EDITOR` if defined. The `$EDITOR` command is only run in the currently active `tmux` pane, if using the `tmux` integration.    |\n| \u003ckbd\u003eAlt/Option\u003c/kbd\u003e + \u003ckbd\u003eo\u003c/kbd\u003e     | Open `$EDITOR` to selected directory without `cd`ing the shell.                                                                                                            |\n| \u003ckbd\u003eCtrl\u003c/kbd\u003e + \u003ckbd\u003eo\u003c/kbd\u003e           | `cd` to selected directory _only in current `tmux` pane_, do not send `cd` command to other `tmux` panes.                                                                  |\n| \u003ckbd\u003eTab\u003c/kbd\u003e                           | Insert the selected directory path to the command line, but do not execute anything. Works in Fish and zsh only, in bash, acts the same as \u003ckbd\u003eCtrl\u003c/kbd\u003e + \u003ckbd\u003eo\u003c/kbd\u003e. |\n| \u003ckbd\u003eCtrl\u003c/kbd\u003e + \u003ckbd\u003ed\u003c/kbd\u003e           | Scroll preview up.                                                                                                                                                         |\n| \u003ckbd\u003eCtrl\u003c/kbd\u003e + \u003ckbd\u003ef\u003c/kbd\u003e           | Scroll preview down.                                                                                                                                                       |\n\n## Configuration\n\n`ctrlg` will look for a configuration file at `~/.config/ctrlg/config.yml`. The default\nconfiguration is shown below:\n\n```yaml\n# include other configuration files into this configuration file,\n# does not search recursively (e.g. you cannot `include` file from\n# an already `include`d file). The `include` key is a yaml list\n# of file paths to include\ninclude: []\n# configure what directories to list in the fuzzy finder\n# can be any list of globbing patterns, will only show directories\n# not files\nsearch_dirs:\n  - \"~/git/*\"\n# globbing patterns of files to find for use as preview\n# see below for more details on previews\npreview_files:\n  - \"README.*\"\n# enable or disable the preview window\npreviews: true\n# force using or not using `glow` for previews\n# this setting takes precedence over `preview_with_bat`\n# this represents the default but in an actual\n# config file, this should just be `true` or `false`\npreview_with_glow: (true if `glow` is installed, false otherwise)\n# set the line-wrap width passed to `glow` via `glow -w`\nglow_wrap_width: 80\n# force using or not using `bat` for previews\n# this represents the default but in an actual\n# config file, this should just be `true` or `false`\npreview_with_bat: (true if `bat` is installed and `glow` is NOT installed, false otherwise)\n# force using or not using `exa` for preview fallback when no\n# matching `preview_files` are found\n# this represents the default but in an actual\n# config file, this should just be `true` or `false`\npreview_fallback_exa: (true if `exa` is installed, false otherwise)\n# enable or disable showing git branch for directories\n# which are git repositories\nshow_git_branch: true\n# character to render between the directory name and git branch name\n# you can change this to a Nerd Font symbol if you like\n# such as git branch symbol: \ngit_branch_separator: \"■\"\n# customize color scheme\n# see section \"Color Schemes\" below for more details\ncolors:\n  # directory name color\n  dir_name: \"cyan\"\n  # git branch color\n  git_branch: \"247,78,39\" # this is git's brand orange color\n  # name of theme to use for `bat`\n  # see: https://github.com/sharkdp/bat#highlighting-theme\n  bat_theme: \"ansi\"\n```\n\n### Previews\n\nPreviews, if enabled, are generated by rendering the first file in each directory\nmatching any of the specified `preview_files` globbing patterns. If a matching file\nis found, it will be rendered with [bat](https://github.com/sharkdp/bat) by default\nif `bat` is installed, otherwise it will be rendered with `cat`. You can force using\nor not using `bat` with the `preview_with_bat` option. You can default to always\nusing the fallback instead of rendering a file by setting an empty list of globbing\npatterns, like: `preview_files: []`.\n\nIf no matching preview files are found, the directory listing is used as the preview. By\ndefault, directory contents are listed using [exa](https://github.com/ogham/exa) by default\nif `exa` is installed, otherwise contents are listed using `ls`. You can force using or not\nusing `exa` as the fallback preview using the `preview_fallback_exa` option.\n\n### Color Schemes\n\nColors in the config file may be specified as a named color,\na single integer corresponding to [xterm-256 color codes](https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg),\nor an RGB triple of integers (e.g. `255,255,255`). If an invalid color is specified\n(e.g. if you use decimals instead of integers, or an invalid named color), it will default to\nwhite. For `xterm-256` or RGB colors to work, it must be supported by your terminal emulator.\nI recommend [Kitty](https://sw.kovidgoyal.net/kitty/).\n\nNamed colors are the following:\n\n- `\"black\"`\n- `\"red\"`\n- `\"green\"`\n- `\"yellow\"`\n- `\"blue\"`\n- `\"purple\"`\n- `\"cyan\"`\n- `\"white\"`\n","funding_links":["https://github.com/sponsors/mrjones2014"],"categories":["cli"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrjones2014%2Fctrlg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrjones2014%2Fctrlg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrjones2014%2Fctrlg/lists"}