mirror of
https://gitlab.com/sagidayan/linux-config.git
synced 2024-11-14 03:35:26 +00:00
38 lines
665 B
Bash
38 lines
665 B
Bash
|
#!/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
|
||
|
|
||
|
|
||
|
|