GithubHelp home page GithubHelp logo

fzf-git.sh's Introduction

fzf-git.sh

bash and zsh key bindings for Git objects, powered by fzf.

image

Each binding will allow you to browse through Git objects of a certain type, and select the objects you want to paste to your command-line.

Installation

  1. Install the latest version of fzf
    • (Optional) Install bat for syntax-highlighted file previews
  2. Source fzf-git.sh file from your .bashrc or .zshrc

Usage

  • List of bindings

    • CTRL-GCTRL-F for Files
    • CTRL-GCTRL-B for Branches
    • CTRL-GCTRL-T for Tags
    • CTRL-GCTRL-R for Remotes
    • CTRL-GCTRL-H for commit Hashes
    • CTRL-GCTRL-S for Stashes
    • CTRL-GCTRL-L for reflogs
    • CTRL-GCTRL-E for Each ref (git for-each-ref)

    ⚠️ You may have issues with these bindings in the following cases:

    • CTRL-GCTRL-B will not work if CTRL-B is used as the tmux prefix
    • CTRL-GCTRL-S will not work if flow control is enabled, CTRL-S will freeze the terminal instead
      • (stty -ixon will disable it)

    To workaround the problems, you can use CTRL-G{key} instead of CTRL-GCTRL-{KEY}.

    ⚠️ If zsh's KEYTIMEOUT is too small (e.g. 1), you may not be able to hit two keys in time.

  • Inside fzf

    • TAB or SHIFT-TAB to select multiple objects
    • CTRL-/ to change preview window layout
    • CTRL-O to open the object in the web browser (in GitHub URL scheme)

Customization

# Redefine this function to change the options
_fzf_git_fzf() {
  fzf-tmux -p80%,60% -- \
    --layout=reverse --multi --height=50% --min-height=20 --border \
    --border-label-pos=2 \
    --color='header:italic:underline,label:blue' \
    --preview-window='right,50%,border-left' \
    --bind='ctrl-/:change-preview-window(down,50%,border-top|hidden|)' "$@"
}

Defining shortcut commands

Each binding is backed by _fzf_git_* function so you can do something like this in your shell configuration file.

gco() {
  local selected=$(_fzf_git_each_ref --no-multi)
  [ -n "$selected" ] && git checkout "$selected"
}

fzf-git.sh's People

Contributors

jpalus avatar junegunn avatar mathieu-lemay avatar ndegory avatar ptzz avatar raine avatar stoyandimov avatar timsu92 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.