2022-01-20 18:12:28 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
JSON_PATH=~/.shellconfig/workspaces/workspaces.json
|
|
|
|
|
|
|
|
WSP=$(cat ${JSON_PATH} \
|
|
|
|
| jq -r 'keys[]' \
|
|
|
|
| fzf --reverse --header "Select a Project to open"
|
|
|
|
)
|
|
|
|
|
2022-02-02 08:13:19 +00:00
|
|
|
if [ -z "$WSP" ]; then
|
2022-01-20 18:12:28 +00:00
|
|
|
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'
|
|
|
|
)
|
2022-02-02 08:13:19 +00:00
|
|
|
IS_CMD=$(cat ${JSON_PATH} \
|
|
|
|
| jq -r --arg WSP "${WSP}" '.[$WSP]|.["is_cmd"] // 0'
|
|
|
|
)
|
2022-01-20 18:12:28 +00:00
|
|
|
cd "$DIR"
|
|
|
|
|
|
|
|
LAYOUT_ARGS=$(echo $LAYOUT | grep -oP "(?<=layout ).*(?)")
|
|
|
|
echo $LAYOUT_ARGS
|
|
|
|
|
|
|
|
tmux neww
|
2022-02-02 08:13:19 +00:00
|
|
|
if [ $IS_CMD -eq 1 ]; then
|
|
|
|
tmux send-keys "${LAYOUT}" C-m
|
|
|
|
tmux rename-window "${WSP}"
|
|
|
|
elif [ ! -z $IS_LAYOUT ]; then
|
|
|
|
tmux send-keys "layout '${LAYOUT_ARGS}' '${WSP}'"
|
2022-01-20 18:12:28 +00:00
|
|
|
else
|
|
|
|
tmux send-keys "${LAYOUT} '${WSP}'" C-m
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|