tmux <prefix>-b to change git branches fast

Uses gitB function from common.sh

Also added confirmation to delete workspace
This commit is contained in:
Sagi Dayan 2022-01-23 14:38:33 +02:00
parent cbe5e8442f
commit f4f315df42
Signed by: sagi
GPG key ID: FAB96BFC63B46458
3 changed files with 26 additions and 5 deletions

View file

@ -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
}

View file

@ -2,6 +2,17 @@
JSON_PATH=~/.shellconfig/workspaces/workspaces.json
function yes_no_question() {
QUESTION=$1
RESPONSE=$(cat <<EOF | fzf --reverse --header "${QUESTION}"
No
Yes
EOF
)
echo $RESPONSE
}
WSP=$(cat ${JSON_PATH} \
| jq -r 'keys[]' \
| fzf --reverse --header "Select a Workspace to DELETE"
@ -12,6 +23,13 @@ if [ -z $WSP ]; then
exit 1
fi
RESPONSE=$(yes_no_question "❓ Are you sure you want to delete ${WSP}?")
if [ "$RESPONSE" == "No" ]; then
echo "Aborted"
exit
fi
echo $(cat ${JSON_PATH} | jq --arg WSP "$WSP" 'del(.[$WSP])') > ${JSON_PATH}
echo "⚠️ '${WSP}' Was removed from your workspaces"

View file

@ -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 <prefix>-b
bind-key b send-keys "gitB" C-m
############################
# Themes
###########################