From f4f315df42d208f2d9d38e6f2bc8c943dc853ed8 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sun, 23 Jan 2022 14:38:33 +0200 Subject: [PATCH] tmux -b to change git branches fast Uses gitB function from common.sh Also added confirmation to delete workspace --- files/dotfiles/shellconfig/common.sh | 8 ++++---- .../shellconfig/workspaces/delete_workspace.sh | 18 ++++++++++++++++++ files/dotfiles/tmux.conf | 5 ++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/files/dotfiles/shellconfig/common.sh b/files/dotfiles/shellconfig/common.sh index faf3b16..47953dc 100644 --- a/files/dotfiles/shellconfig/common.sh +++ b/files/dotfiles/shellconfig/common.sh @@ -41,6 +41,10 @@ export EDITOR=vim; function gitB() { if [ -d ./.git ]; then CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) + if [ $(git branch | wc -l) -lt 2 ]; then + echo "⚠️ Only ${CURRENT_BRANCH} exists." + return 1 + fi BRANCH=$(git branch -l |sed '/\*/d'| fzf --reverse --header="Current Branch: ${CURRENT_BRANCH}. Select Branch to checkout") if [ -z ${BRANCH} ]; then echo Canceled @@ -202,7 +206,3 @@ function grid() { return 0 } - -function add_workspace() { - ~/.shellconfig/workspaces/add_workspace.sh ${1} || return 1 -} diff --git a/files/dotfiles/shellconfig/workspaces/delete_workspace.sh b/files/dotfiles/shellconfig/workspaces/delete_workspace.sh index fa21fc5..346a145 100755 --- a/files/dotfiles/shellconfig/workspaces/delete_workspace.sh +++ b/files/dotfiles/shellconfig/workspaces/delete_workspace.sh @@ -2,6 +2,17 @@ JSON_PATH=~/.shellconfig/workspaces/workspaces.json +function yes_no_question() { + QUESTION=$1 + RESPONSE=$(cat < ${JSON_PATH} echo "⚠️ '${WSP}' Was removed from your workspaces" diff --git a/files/dotfiles/tmux.conf b/files/dotfiles/tmux.conf index a3fc9c0..4f8bb52 100644 --- a/files/dotfiles/tmux.conf +++ b/files/dotfiles/tmux.conf @@ -41,11 +41,14 @@ bind-key i run-shell "tmux neww -n '🏳️ CHEATER\! 😎' ~/.shellconfig/cheat bind-key o run-shell "tmux neww -n '🖥Workspace Manager' ~/.shellconfig/workspaces/open_workspace.sh" # Add/Save Workspace -bind-key a send-keys "add_workspace" C-m +bind-key a run-shell "tmux neww -n '🖥Workspace Manager' 'cd #{pane_current_path} && ~/.shellconfig/workspaces/add_workspace.sh'" # Delete (x) Workspace bind-key x run-shell "tmux neww -n '🖥Workspace Manager' ~/.shellconfig/workspaces/delete_workspace.sh" +# Change git branches fast -b +bind-key b send-keys "gitB" C-m + ############################ # Themes ###########################