mirror of
https://gitlab.com/sagidayan/linux-config.git
synced 2024-11-22 07:15:25 +00:00
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:
parent
cbe5e8442f
commit
f4f315df42
3 changed files with 26 additions and 5 deletions
|
@ -41,6 +41,10 @@ export EDITOR=vim;
|
||||||
function gitB() {
|
function gitB() {
|
||||||
if [ -d ./.git ]; then
|
if [ -d ./.git ]; then
|
||||||
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
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")
|
BRANCH=$(git branch -l |sed '/\*/d'| fzf --reverse --header="Current Branch: ${CURRENT_BRANCH}. Select Branch to checkout")
|
||||||
if [ -z ${BRANCH} ]; then
|
if [ -z ${BRANCH} ]; then
|
||||||
echo Canceled
|
echo Canceled
|
||||||
|
@ -202,7 +206,3 @@ function grid() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function add_workspace() {
|
|
||||||
~/.shellconfig/workspaces/add_workspace.sh ${1} || return 1
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,6 +2,17 @@
|
||||||
|
|
||||||
JSON_PATH=~/.shellconfig/workspaces/workspaces.json
|
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} \
|
WSP=$(cat ${JSON_PATH} \
|
||||||
| jq -r 'keys[]' \
|
| jq -r 'keys[]' \
|
||||||
| fzf --reverse --header "Select a Workspace to DELETE"
|
| fzf --reverse --header "Select a Workspace to DELETE"
|
||||||
|
@ -12,6 +23,13 @@ if [ -z $WSP ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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 $(cat ${JSON_PATH} | jq --arg WSP "$WSP" 'del(.[$WSP])') > ${JSON_PATH}
|
||||||
|
|
||||||
echo "⚠️ '${WSP}' Was removed from your workspaces"
|
echo "⚠️ '${WSP}' Was removed from your workspaces"
|
||||||
|
|
|
@ -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"
|
bind-key o run-shell "tmux neww -n '🖥Workspace Manager' ~/.shellconfig/workspaces/open_workspace.sh"
|
||||||
|
|
||||||
# Add/Save Workspace
|
# 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
|
# Delete (x) Workspace
|
||||||
bind-key x run-shell "tmux neww -n '🖥Workspace Manager' ~/.shellconfig/workspaces/delete_workspace.sh"
|
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
|
# Themes
|
||||||
###########################
|
###########################
|
||||||
|
|
Loading…
Reference in a new issue