Skip to content

CLI tool that enables flexible access to the ghq list and other specified directories using fzf.

Notifications You must be signed in to change notification settings

yumafuu/ghq-fzf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ghq-fzf

This is a simple tool to select ghq repositories using fzf

The configuration allows users to specify a command for preview and to access non-ghq managed repositories with the same command.

Installation

$ brew install yumafuu/tap/ghq-fzf

or manually download from release page.

Usage

This tool cannot be used directly because it involves cd operations. The binary _ghq-fzf will be installed, so you will need to configure your own environment for cd.

# .bashrc or .zshrc
ghq-fzf(){ eval $(_ghq-fzf run) }

And then you can use the following command to select a repository.

$ ghq-fzf

Advanced

# if zsh, ctrl-o is binded to accept-line
ghq-fzf() {
  eval $(_ghq-fzf run)
  zle accept-line
  zle reset-prompt
}

zle -N ghq-fzf
bindkey "^o" ghq-fzf

Configuration

First look for GHQ_FZF_CONFIG and if the file is not there, look for it in the following order.

  • $XDG_CONFIG_HOME/ghq-fzf/config.yaml
  • $HOME/.config/ghq-fzf/config.yaml

If no file was found, create it in the final hit location.

Below is the content of the YAML file:

fzf.preview

This specifies what will be displayed in the fzf preview window. The string configured here will be passed to --preview.

fzf:
  preview: "exa --tree -L 2 $(_ghq-fzf fullpath {})"
  # preview: "bat $(_ghq-fzf fullpath {})/README.md"
  # `_ghq-fzf fullpath` is a helper command designed to obtain the full paths of both ghq-managed directories and any externally configured directories.

Reference: https://github.com/junegunn/fzf#preview-window

ghq

showFullpath: true/false ghq list will show fullpath or not. ( if true, ghq list -p )

Nested: directories under ghq-managed directories will be added to the list. This is useful for monorepos.

ghq:
  showFullpath: true
  nested:
    - root: ${ghq-repo} # github.com/yumafuu/ghq-fzf
      dirs:
       - ${dir-name}

external

Directories not managed by ghq will also be added to the list.

external:
  - ~/Downloads
  - /Applications

Full example.

fzf:
  # preview: "bat $(_ghq-fzf fullpath {})/README.md"
  preview: "exa --tree -L 2 $(_ghq-fzf fullpath {})"

ghq:
  showFullpath: false
  nested:
    - root: github.com/yumafuu/ghq-fzf
      dirs:
        - src
        - .github

external:
  - "~/dotfiles"
  - "~/dotfiles/nvim"
  - "~/Downloads"

About

CLI tool that enables flexible access to the ghq list and other specified directories using fzf.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published