Skip to content

Commit

Permalink
Symlink bin folder, add two git scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKnarf committed May 3, 2024
1 parent 5bcfe66 commit d02e984
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
19 changes: 19 additions & 0 deletions bin/git-fsb
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 "$@"
23 changes: 23 additions & 0 deletions bin/git-fshow
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 "$@"
4 changes: 0 additions & 4 deletions bin/light

This file was deleted.

1 change: 1 addition & 0 deletions setup
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ setup_link "$HOME/.gitconfig" "gitconfig"
setup_link "$HOME/.witchcraft-scripts" "witchcraft-scripts"
setup_link "$HOME/.config/yabai/yabairc" "yabairc"
setup_link "$HOME/.config/skhd/skhdrc" "skhdrc"
setup_link "$HOME/.bin" "bin"

# -----------------------------------------
# Vim setup
Expand Down
1 change: 1 addition & 0 deletions zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ path+=(
'/usr/local/git/bin'
"$HOME/Dropbox/Projects/depot_tools"
"$HOME/bin"
"$HOME/.bin"
"$HOME/Library/Haskell/bin"
'./node_modules/.bin'
'./vendor/bin' # PHP Composer bin folder
Expand Down

0 comments on commit d02e984

Please sign in to comment.