Demo is using the tmux integration for floating window and lighthaus terminal theme.
Ctrlg is a tool to quickly switch contexts to another directory, using a fuzzy finder.
If enabled (by setting $CTRLG_TMUX
to true
), ctrlg
can cd
all split panes in the current window of a tmux
session
to the selected directory. Press ctrl + g to fuzzy find directories,
configured by globbing patterns.
By default, only ~/git/*
is searched. To change this or add additional
directories to search, see configuration.
sh
cargo install ctrlg
cargo
can be installed via rustup.rs.
Do not run as root or with sudo
, the script will ask for sudo
if needed.
sh
bash -c 'bash <(curl --proto "=https" --tlsv1.2 -sSf https://raw.githubusercontent.com/mrjones2014/ctrlg/master/install.bash)'
ctrlg
chmod +x ctrlg
$PATH
, such as /usr/local/bin/ctrlg
Requires cargo
:
sh
git clone git@github.com:mrjones2014/ctrlg.git
cd ctrlg
cargo install --path .
Once the CLI is installed, you will need to set up the key binding depending on your shell.
Alternatively, you can disable the default keybind by setting $CTRLG_NOBIND
to true
before running the init script, then set up your own keybind to call _ctrlg_search_and_go
.
fish
echo 'ctrlg init fish | source' >> ~/.config/fish/config.fish
zsh
echo 'eval "$(ctrlg init zsh)"' >> ~/.zshrc
bash
echo 'eval "$(ctrlg init bash)"' >> ~/.bashrc
To make ctrlg
send the cd
command to all split panes in the current tmux
window, set the environment variable CTRLG_TMUX
to true
. You can also make the fuzzy finder
appear in a tmux
floating window, and specify the window size, with $CTRLG_TMUX_POPUP
and
$CTRLG_TMUX_POPUP_ARGS
, respectively. $CTRLG_TMUX_POPUP_ARGS
can be any window positioning
or sizing arguments accepted by tmux popup
. $CTRLG_TMUX_POPUP_ARGS
defaults to -w 75% -h 75%
.
```fish set CTRLGTMUX true set CTRLGTMUX_POPUP true
set CTRLGTMUXPOPUP_ARGS "-w" "75%" "-h" "75%" ```
```bash export CTRLGTMUX=true export CTRLGTMUX_POPUP=true
export CTRLGTMUXPOPUP_ARGS="-w 75% -h 75%" ```
| Key Binding | Function |
| ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Enter | cd
to the selected directory. If $CTRLG_TMUX
is true
, the cd
command is sent to all split panes in the current window. |
| Alt/Option + Enter | 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. |
| Alt/Option + o | Open $EDITOR
to selected directory without cd
ing the shell. |
| Ctrl + o | cd
to selected directory only in current tmux
pane, do not send cd
command to other tmux
panes. |
| Tab | 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 Ctrl + o. |
| Ctrl + d | Scroll preview up. |
| Ctrl + f | Scroll preview down. |
ctrlg
will look for a configuration file at ~/.config/ctrlg/config.yml
. The default
configuration is shown below:
```yaml
search_dirs: - "~/git/*"
preview_files: - "README.*"
previews: true
bat
for previewstrue
or false
previewwithbat: [true if bat
is installed, false otherwise]
exa
for preview fallback when nopreview_files
are foundtrue
or false
previewfallbackexa: [true if exa
is installed, false otherwise]
showgitbranch: true
gitbranchseparator: "■"
colors:
# directory name color
dirname: "cyan"
# git branch color
gitbranch: "247,78,39" # this is git's brand orange color
# name of theme to use for bat
# see: https://github.com/sharkdp/bat#highlighting-theme
bat_theme: "ansi"
```
Previews, if enabled, are generated by rendering the first file in each directory
matching any of the specified preview_files
globbing patterns. If a matching file
is found, it will be rendered with bat by default
if bat
is installed, otherwise it will be rendered with cat
. You can force using
or not using bat
with the preview_with_bat
option. You can default to always
using the fallback instead of rendering a file by setting an empty list of globbing
patterns, like: preview_files: []
.
If no matching preview files are found, the directory listing is used as the preview. By
default, directory contents are listed using exa by default
if exa
is installed, otherwise contents are listed using ls
. You can force using or not
using exa
as the fallback preview using the preview_fallback_exa
option.
Colors in the config file may be specified as a named color,
a single integer corresponding to xterm-256 color codes,
or an RGB triple of integers (e.g. 255,255,255
). If an invalid color is specified
(e.g. if you use decimals instead of integers, or an invalid named color), it will default to
white. For xterm-256
or RGB colors to work, it must be supported by your terminal emulator.
I recommend Kitty.
Named colors are the following:
"black"
"red"
"green"
"yellow"
"blue"
"purple"
"cyan"
"white"