/foryadm

port of forgit that uses yadm, to manage your dotfiles

Primary LanguageShellMIT LicenseMIT

💤 foryadm

Utility tool for using yadm interactively. Powered by junegunn/fzf.

pre-commit Contributors

This tool is designed to help you use yadm more efficiently. It's lightweight and easy to use.

📥 Installation

Make sure you have fzf installed.

# for zplug
zplug 'indianboy42/foryadm'

# for zgen
zgen load 'indianboy42/foryadm'

# for antigen
antigen bundle 'indianboy42/foryadm'

# for fisher
fisher install indianboy42/foryadm

# for omf
omf install https://github.com/indianboy42/foryadm

# for zinit
zinit load indianboy42/foryadm

# manually
# Clone the repository and source it in your shell's rc file.

You can run the following command to try forgit without installing:

# for bash / zsh
source <(curl -sSL git.io/forgit)
# for fish
source (curl -sSL git.io/forgit-fish | psub)

📝 Features

  • Interactive yadm add selector (ga)

screenshot

  • Interactive yadm log viewer (glo)

screenshot

The log graph can be disabled by option FORYADM_LOG_GRAPH_ENABLE (see discuss in issue #71).

  • Interactive .gitignore generator (gi)

screenshot

  • Interactive yadm diff viewer (gd)

  • Interactive yadm reset HEAD <file> selector (grh)

  • Interactive yadm checkout <file> selector (gcf)

  • Interactive yadm checkout <branch> selector (gcb)

  • Interactive yadm checkout <commit> selector (gco)

  • Interactive yadm stash viewer (gss)

  • Interactive yadm clean selector (gclean)

  • Interactive yadm cherry-pick selector (gcp)

  • Interactive yadm rebase -i selector (grb)

  • Interactive yadm commit --fixup && yadm rebase -i --autosquash selector (gfu)

⌨ Keybinds

Key Action
Enter Confirm
Tab Toggle mark and move up
Shift - Tab Toggle mark and move down
? Toggle preview window
Alt - W Toggle preview wrap
Ctrl - S Toggle sort
Ctrl - R Toggle selection
Ctrl - Y Copy commit hash*
Ctrl - K / P Selection move up
Ctrl - J / N Selection move down
Alt - K / P Preview move up
Alt - J / N Preview move down

* Available when the selection contains a commit hash. For linux users FORYADM_COPY_CMD should be set to make copy work. Example: FORYADM_COPY_CMD='xclip -selection clipboard'.

⚙ Options

aliases

You can change the default aliases by defining these variables below. (To disable all aliases, Set the FORYADM_NO_ALIASES flag.)

foryadm_log=yadlo
foryadm_diff=yadiff
foryadm_add=yadd
foryadm_reset_head=yadrh
foryadm_ignore=yadi
foryadm_checkout_file=yadcf
foryadm_checkout_branch=yadcb
foryadm_checkout_commit=yadco
foryadm_clean=yadclean
foryadm_stash_show=yadss
foryadm_cherry_pick=yadcp
foryadm_rebase=yadrb
foryadm_fixup=yadfu

pagers

Foryadm will use the default configured pager from yadm (core.pager, pager.show, pager.diff) but can be altered with the following environment variables:

Use case Option Fallbacks to
common pager FORYADM_PAGER git config core.pager or cat
pager on yadm show FORYADM_SHOW_PAGER git config pager.show or $FORYADM_PAGER
pager on yadm diff FORYADM_DIFF_PAGER git config pager.diff or $FORYADM_PAGER
pager on gitignore FORYADM_IGNORE_PAGER bat -l gitignore --color always or cat
yadm log format FORYADM_GLO_FORMAT %C(auto)%h%d %s %C(black)%C(bold)%cr%reset

fzf options

You can add default fzf options for forgit, including keybinds, layout, etc. (No need to repeat the options already defined in FZF_DEFAULT_OPTS)

FORYADM_FZF_DEFAULT_OPTS="
--exact
--border
--cycle
--reverse
--height '80%'
"

Customizing fzf options for each command individually is also supported:

Command Option
ga FORYADM_ADD_FZF_OPTS
glo FORYADM_LOG_FZF_OPTS
gi FORYADM_IGNORE_FZF_OPTS
gd FORYADM_DIFF_FZF_OPTS
grh FORYADM_RESET_HEAD_FZF_OPTS
gcf FORYADM_CHECKOUT_FILE_FZF_OPTS
gcb FORYADM_CHECKOUT_BRANCH_FZF_OPTS
gco FORYADM_CHECKOUT_COMMIT_FZF_OPTS
gss FORYADM_STASH_FZF_OPTS
gclean FORYADM_CLEAN_FZF_OPTS
grb FORYADM_REBASE_FZF_OPTS
gfu FORYADM_FIXUP_FZF_OPTS

Complete loading order of fzf options is:

  1. FZF_DEFAULT_OPTS (fzf global)
  2. FORYADM_FZF_DEFAULT_OPTS (foryadm global)
  3. FORYADM_CMD_FZF_OPTS (command specific)

Examples:

  • ctrl-d to drop the selected stash but do not quit fzf (gss specific).
FORYADM_STASH_FZF_OPTS='
--bind="ctrl-d:reload(yadm stash drop $(cut -d: -f1 <<<{}) 1>/dev/null && yadm stash list)"
'
  • ctrl-e to view the logs in a vim buffer (glo specific).
FORYADM_LOG_FZF_OPTS='
--bind="ctrl-e:execute(echo {} |grep -Eo [a-f0-9]+ |head -1 |xargs yadm show |vim -)"
'

other options

Option Description Default
FORYADM_LOG_FORMAT yadm log format %C(auto)%h%d %s %C(black)%C(bold)%cr%Creset

📦 Optional dependencies

💡 Tips

  • Most of the commands accept optional arguments (eg, glo develop, glo f738479..188a849b -- main.go, gco master).
  • gd supports specifying revision(eg, gd HEAD~, gd v1.0 README.md).
  • Call gi with arguments to get the wanted .gitignore contents directly(eg, gi cmake c++).
  • You can use the commands as sub-commands of git, see #147 for details.

📃 License

MIT (c) Wenxuan Zhang