GithubHelp home page GithubHelp logo

git-log-interactive's Introduction

git-log-interactive

Intro

This is git log for cool kids: Quick Demo

Usage

  1. Run in your terminal gli to invoke the function.
  2. To do a fuzzy search, just start typing.
  3. To view all changes in fullscreen, highlight a commit and press ENTER, press q to exit fullscreen.
  4. To copy a commit hash to your clipboard, press CTRL-C.
  5. To exit the function, press ESC.

Setup

Note: This function uses fzf and diff-so-fancy, make sure they're both installed.

  1. Navigate to your root directory with cd ~.
  2. Open your .zshrc file with nano .zshrc.
  3. Copy and paste the shell function at the bottom of the file:
 function gli() {
   local git_log_line_to_hash="echo {} | grep -o '[a-f0-9]\{7\}' | head -1"
   local view_git_log_line="${git_log_line_to_hash} | xargs -I % sh -c 'git show --color=always % | diff-so-fancy'"

   git log \
       --color=always \
       --format="%C(cyan)%h %C(blue)%ar%C(auto)%d %C(yellow)%s%+b %C(black)%ae" "$@" | \
   fzf -i -e +s \
       --reverse \
       --tiebreak=index \
       --no-multi \
       --ansi \
       --preview="${view_git_log_line}" \
       --header "ENTER: View in pager, CTRL+C: Copy hash" \
       --bind "enter:execute:${view_git_log_line} | less -R" \
       --bind "ctrl-c:execute:${git_log_line_to_hash} | pbcopy"
 }
  1. To save the file, press CTRL-X, then Y, then ENTER.
  2. Apply the changes with source ~/.zshrc.

Note: If you're using bash, follow the same steps but replace .zshrc with .bashrc.

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.