2022-01-20 18:12:28 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
JSON_PATH=~/.shellconfig/workspaces/workspaces.json
|
|
|
|
|
2022-01-23 12:38:33 +00:00
|
|
|
function yes_no_question() {
|
|
|
|
QUESTION=$1
|
|
|
|
RESPONSE=$(cat <<EOF | fzf --reverse --header "${QUESTION}"
|
|
|
|
No
|
|
|
|
Yes
|
|
|
|
EOF
|
|
|
|
)
|
|
|
|
|
|
|
|
echo $RESPONSE
|
|
|
|
}
|
|
|
|
|
2022-01-20 18:12:28 +00:00
|
|
|
WSP=$(cat ${JSON_PATH} \
|
|
|
|
| jq -r 'keys[]' \
|
|
|
|
| fzf --reverse --header "Select a Workspace to DELETE"
|
|
|
|
)
|
|
|
|
|
|
|
|
if [ -z $WSP ]; then
|
|
|
|
echo "Aborted"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-01-23 12:38:33 +00:00
|
|
|
RESPONSE=$(yes_no_question "❓ Are you sure you want to delete ${WSP}?")
|
|
|
|
|
|
|
|
if [ "$RESPONSE" == "No" ]; then
|
|
|
|
echo "Aborted"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2022-01-20 18:12:28 +00:00
|
|
|
echo $(cat ${JSON_PATH} | jq --arg WSP "$WSP" 'del(.[$WSP])') > ${JSON_PATH}
|
|
|
|
|
|
|
|
echo "⚠️ '${WSP}' Was removed from your workspaces"
|