-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Symlink bin folder, add two git scripts
- Loading branch information
Showing
5 changed files
with
44 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
# Taken from: https://github.com/exosyphon/dotfiles/blob/main/scripts/fsb.sh | ||
# https://www.youtube.com/watch?v=-B5MTJXW-vA | ||
|
||
# Fuzzy search Git branches in a repo | ||
# Looks for local and remote branches | ||
function fsb() { | ||
local pattern=$* | ||
local branches branch | ||
branches=$(git branch --all | awk 'tolower($0) ~ /'"$pattern"'/') && | ||
branch=$(echo "$branches" | | ||
fzf-tmux -p --reverse -1 -0 +m) && | ||
if [ "$branch" = "" ]; then | ||
echo "[$0] No branch matches the provided pattern"; return; | ||
fi; | ||
git checkout "$(echo "$branch" | sed "s/.* //" | sed "s#remotes/[^/]*/##")" | ||
} | ||
fsb "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
# Taken from: https://github.com/exosyphon/dotfiles/blob/main/scripts/fsb.sh | ||
# https://www.youtube.com/watch?v=-B5MTJXW-vA | ||
|
||
# Fuzzy search over Git commits | ||
# Enter will view the commit | ||
# Ctrl-o will checkout the selected commit | ||
function fshow() { | ||
git log --graph --color=always \ | ||
--format="%C(auto)%h%d %s %C(black)%C(bold)%cr" "$@" | | ||
fzf --ansi --no-sort --reverse --tiebreak=index --bind=ctrl-s:toggle-sort --preview \ | ||
'f() { set -- $(echo -- "$@" | grep -o "[a-f0-9]\{7\}"); [ $# -eq 0 ] || git show --color=always $1 ; }; f {}' \ | ||
--header "enter to view, ctrl-o to checkout" \ | ||
--bind "q:abort,ctrl-f:preview-page-down,ctrl-b:preview-page-up" \ | ||
--bind "ctrl-o:become:(echo {} | grep -o '[a-f0-9]\{7\}' | head -1 | xargs git checkout)" \ | ||
--bind "ctrl-m:execute: | ||
(grep -o '[a-f0-9]\{7\}' | head -1 | | ||
xargs -I % sh -c 'git show --color=always % | less -R') << 'FZF-EOF' | ||
{} | ||
FZF-EOF" --preview-window=right:60% | ||
} | ||
fshow "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters