Skip to content

Commit

Permalink
Merge pull request #588 from JRasmusBm/584-idea-speed-dial-for-git-br…
Browse files Browse the repository at this point in the history
…anches

feat: support branch speeddial
  • Loading branch information
JRasmusBm authored Apr 6, 2024
2 parents debad75 + d8f7e41 commit cd07707
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 14 deletions.
35 changes: 35 additions & 0 deletions bin/gb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh

set -e

_git_branch_speeddial() {
(
_file_name="$(git rev-parse --show-toplevel)/.git/branch_speeddial"
if test $1 = 'e' -o $1 = 'edit'; then
nvim "$_file_name"
return 0
fi

if ! test -e "$_file_name" ; then
echo "No config file exists at $_file_name"
return 1
fi



_line="$1"
if test "$_line" = '0'; then
_line='10'
fi

_branch_name="$(head -"$_line" <"$_file_name" | tail -1)"
if test -z "$_branch_name"; then
echo "No branch name specified on line $_line"
return 1
fi

git switch "$_branch_name"
)
}

_git_branch_speeddial "$@"
90 changes: 77 additions & 13 deletions terminal/alacritty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ scrolling:
# I always like large history
history: 100000

# I use tmux copy-mode
# I use tmux copy-mode
selection:
save_to_clipboard: false

Expand All @@ -32,15 +32,79 @@ mouse:
hide_when_typing: true

key_bindings:
- { key: 17, mods: Alt, chars: "\et" }
- { key: 35, mods: Alt, chars: "\ep" }
- { key: 18, mods: Alt, chars: "\e1" }
- { key: 19, mods: Alt, chars: "\e2" }
- { key: 20, mods: Alt, chars: "\e3" }
- { key: 21, mods: Alt, chars: "\e4" }
- { key: 23, mods: Alt, chars: "\e5" }
- { key: 22, mods: Alt, chars: "\e6" }
- { key: 26, mods: Alt, chars: "\e7" }
- { key: 28, mods: Alt, chars: "\e8" }
- { key: 25, mods: Alt, chars: "\e9" }
- { key: 29, mods: Alt, chars: "\e0" }
- { key: A, mods: Alt, chars: "\x1ba" }
- { key: B, mods: Alt, chars: "\x1bb" }
- { key: C, mods: Alt, chars: "\x1bc" }
- { key: D, mods: Alt, chars: "\x1bd" }
- { key: E, mods: Alt, chars: "\x1be" }
- { key: F, mods: Alt, chars: "\x1bf" }
- { key: G, mods: Alt, chars: "\x1bg" }
- { key: H, mods: Alt, chars: "\x1bh" }
- { key: I, mods: Alt, chars: "\x1bi" }
- { key: J, mods: Alt, chars: "\x1bj" }
- { key: K, mods: Alt, chars: "\x1bk" }
- { key: L, mods: Alt, chars: "\x1bl" }
- { key: M, mods: Alt, chars: "\x1bm" }
- { key: N, mods: Alt, chars: "\x1bn" }
- { key: O, mods: Alt, chars: "\x1bo" }
- { key: P, mods: Alt, chars: "\x1bp" }
- { key: Q, mods: Alt, chars: "\x1bq" }
- { key: R, mods: Alt, chars: "\x1br" }
- { key: S, mods: Alt, chars: "\x1bs" }
- { key: T, mods: Alt, chars: "\x1bt" }
- { key: U, mods: Alt, chars: "\x1bu" }
- { key: V, mods: Alt, chars: "\x1bv" }
- { key: W, mods: Alt, chars: "\x1bw" }
- { key: X, mods: Alt, chars: "\x1bx" }
- { key: Y, mods: Alt, chars: "\x1by" }
- { key: Z, mods: Alt, chars: "\x1bz" }
- { key: A, mods: Alt|Shift, chars: "\x1bA" }
- { key: B, mods: Alt|Shift, chars: "\x1bB" }
- { key: C, mods: Alt|Shift, chars: "\x1bC" }
- { key: D, mods: Alt|Shift, chars: "\x1bD" }
- { key: E, mods: Alt|Shift, chars: "\x1bE" }
- { key: F, mods: Alt|Shift, chars: "\x1bF" }
- { key: G, mods: Alt|Shift, chars: "\x1bG" }
- { key: H, mods: Alt|Shift, chars: "\x1bH" }
- { key: I, mods: Alt|Shift, chars: "\x1bI" }
- { key: J, mods: Alt|Shift, chars: "\x1bJ" }
- { key: K, mods: Alt|Shift, chars: "\x1bK" }
- { key: L, mods: Alt|Shift, chars: "\x1bL" }
- { key: M, mods: Alt|Shift, chars: "\x1bM" }
- { key: N, mods: Alt|Shift, chars: "\x1bN" }
- { key: O, mods: Alt|Shift, chars: "\x1bO" }
- { key: P, mods: Alt|Shift, chars: "\x1bP" }
- { key: Q, mods: Alt|Shift, chars: "\x1bQ" }
- { key: R, mods: Alt|Shift, chars: "\x1bR" }
- { key: S, mods: Alt|Shift, chars: "\x1bS" }
- { key: T, mods: Alt|Shift, chars: "\x1bT" }
- { key: U, mods: Alt|Shift, chars: "\x1bU" }
- { key: V, mods: Alt|Shift, chars: "\x1bV" }
- { key: W, mods: Alt|Shift, chars: "\x1bW" }
- { key: X, mods: Alt|Shift, chars: "\x1bX" }
- { key: Y, mods: Alt|Shift, chars: "\x1bY" }
- { key: Z, mods: Alt|Shift, chars: "\x1bZ" }
- { key: Key1, mods: Alt, chars: "\x1b1" }
- { key: Key2, mods: Alt, chars: "\x1b2" }
- { key: Key3, mods: Alt, chars: "\x1b3" }
- { key: Key4, mods: Alt, chars: "\x1b4" }
- { key: Key5, mods: Alt, chars: "\x1b5" }
- { key: Key6, mods: Alt, chars: "\x1b6" }
- { key: Key7, mods: Alt, chars: "\x1b7" }
- { key: Key8, mods: Alt, chars: "\x1b8" }
- { key: Key9, mods: Alt, chars: "\x1b9" }
- { key: Key0, mods: Alt, chars: "\x1b0" }
- { key: Space, mods: Control, chars: "\x00" }
- { key: Grave, mods: Alt, chars: "\x1b`" }
- { key: Grave, mods: Alt|Shift, chars: "\x1b~" }
- { key: Period, mods: Alt, chars: "\x1b." }
- { key: Key8, mods: Alt|Shift, chars: "\x1b*" }
- { key: Key3, mods: Alt|Shift, chars: "\x1b#" }
- { key: Period, mods: Alt|Shift, chars: "\x1b>" }
- { key: Comma, mods: Alt|Shift, chars: "\x1b<" }
- { key: Minus, mods: Alt|Shift, chars: "\x1b_" }
- { key: Key5, mods: Alt|Shift, chars: "\x1b%" }
- { key: Key6, mods: Alt|Shift, chars: "\x1b^" }
- { key: Backslash, mods: Alt, chars: "\x1b\\" }
- { key: Backslash, mods: Alt|Shift, chars: "\x1b|" }
- { key: Semicolon, mods: Alt, chars: "\x1b;" }
17 changes: 16 additions & 1 deletion tmux/tmux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bind C-h split-window -v "htop"
# Don't suspend tmux
unbind-key C-z

# Speed Dial
# Project speed dial
bind-key -n "M-p" split-window -v "tsp"
bind-key -n "M-1" run-shell "tmux-speeddial 1"
bind-key -n "M-2" run-shell "tmux-speeddial 2"
Expand All @@ -68,6 +68,21 @@ bind-key -n "M-9" run-shell "tmux-speeddial 9"
bind-key -n "M-0" run-shell "tmux-speeddial 10"
bind-key -n "M-t" split-window -v -l 70% tsp e

# Branch speed dial

bind-key -n "M-;" split-window -v "gb e"
bind-key -Tbranch-speeddial "1" run-shell "gb 1"
bind-key -Tbranch-speeddial "2" run-shell "gb 2"
bind-key -Tbranch-speeddial "3" run-shell "gb 3"
bind-key -Tbranch-speeddial "4" run-shell "gb 4"
bind-key -Tbranch-speeddial "5" run-shell "gb 5"
bind-key -Tbranch-speeddial "6" run-shell "gb 6"
bind-key -Tbranch-speeddial "7" run-shell "gb 7"
bind-key -Tbranch-speeddial "8" run-shell "gb 8"
bind-key -Tbranch-speeddial "9" run-shell "gb 9"
bind-key -Tbranch-speeddial "0" run-shell "gb 10"
bind-key ";" switch-client -Tbranch-speeddial

# Run commands
bind t split-window -v -l 70% -c ~/todoist
bind f split-window -v "g fc"
Expand Down

0 comments on commit cd07707

Please sign in to comment.