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}"
|
2022-01-24 09:54:38 +00:00
|
|
|
|
⨯ No
|
|
|
|
|
🗸 Yes
|
2022-01-23 12:38:33 +00:00
|
|
|
|
EOF
|
2022-01-24 09:54:38 +00:00
|
|
|
|
)
|
|
|
|
|
echo $(echo $RESPONSE | awk '{print $2}')
|
2022-01-23 12:38:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-20 18:12:28 +00:00
|
|
|
|
WSP=$(cat ${JSON_PATH} \
|
|
|
|
|
| jq -r 'keys[]' \
|
|
|
|
|
| fzf --reverse --header "Select a Workspace to DELETE"
|
|
|
|
|
)
|
|
|
|
|
|
2022-01-24 09:54:38 +00:00
|
|
|
|
if [ -z "$WSP" ]; then
|
2022-01-20 18:12:28 +00:00
|
|
|
|
echo "Aborted"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2022-01-24 09:54:38 +00:00
|
|
|
|
RESPONSE="$(yes_no_question "❓ Are you sure you want to delete ${WSP}?")"
|
2022-01-23 12:38:33 +00:00
|
|
|
|
|
|
|
|
|
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"
|