linux-config/files/dotfiles/shellconfig/workspaces/open_workspace.sh

38 lines
665 B
Bash
Raw Normal View History

#!/bin/bash
JSON_PATH=~/.shellconfig/workspaces/workspaces.json
WSP=$(cat ${JSON_PATH} \
| jq -r 'keys[]' \
| fzf --reverse --header "Select a Project to open"
)
if [ -z $WSP ]; then
echo "Aborted"
exit 1
fi
DIR=$(cat ${JSON_PATH} \
| jq -r --arg WSP "${WSP}" '.[$WSP]|.["dir"]' \
| tr -d '\r'
)
LAYOUT=$(cat ${JSON_PATH} \
| jq -r --arg WSP "${WSP}" '.[$WSP]|.["layout"]' \
| tr -d '\r'
)
cd "$DIR"
LAYOUT_ARGS=$(echo $LAYOUT | grep -oP "(?<=layout ).*(?)")
echo $LAYOUT_ARGS
tmux neww
if [ ! -z $IS_LAYOUT ]; then
tmux send-keys "layout '${LAYOUT_ARGS}' '${WPS}'"
else
tmux send-keys "${LAYOUT} '${WSP}'" C-m
fi