Skip to content

Instantly share code, notes, and snippets.

View imambungo's full-sized avatar

M Imam Pratama imambungo

View GitHub Profile
@imambungo
imambungo / gist:54481ed60fbf11e599fc1ab37677eee2
Last active March 24, 2020 17:23 — forked from junegunn/gist:f4fca918e937e6bf5bad
Browsing git commit history with fzf
# https://gist.github.com/junegunn/f4fca918e937e6bf5bad#gistcomment-2731105
# my git log
mgl()
{
local the_git_log = 'git log --graph --pretty=format:"%C(bold blue)%s%C(auto)%d%n%C(yellow)%h%Creset %an, %C(magenta)%ar%Creset at %C(cyan)%ad%n%b" --date=format:"%H:%M" --author-date-order --all'
ggloga --color=always | \
fzf --ansi --no-sort --reverse --tiebreak=index --preview \
'source ~/.alias; f() { set -- $(echo -- "$@" | grep -o "[a-f0-9]\{7\}"); [ $# -eq 0 ] || git show --color=always $1 ; }; f \
"$(the_git_log | head -$(({n} + 2)) | tail -2)"' \
--bind 'ctrl-j:preview-down,ctrl-k:preview-up,alt-j:preview-page-down,alt-k:preview-page-up,ctrl-m:execute: \
@imambungo
imambungo / github
Last active March 12, 2021 07:13 — forked from igrigorik/github.bash
Open GitHub URL for current directory/repo...
#!/usr/bin/env bash
# usage: gh [file]
gh() {
repoURL=$(git config remote.origin.url | sed "s~git@\(.*\):\(.*\)~https://\1/\2~" | sed "s~\(.*\).git\$~\1~")
branch=$(git branch | grep \* | cut -d ' ' -f2)
relativePath=$(git rev-parse --show-prefix)
google-chrome "$repoURL/tree/$branch/$relativePath$1"
}