linux-config/files/dotfiles/shellconfig/workspaces/open_workspace.sh
Sagi Dayan 79ab87fa07
Simple tmux based workspace manager
- tmux key-bindings for save/open/delete workspace
- each workspace has a layout based on common.sh functions such as `ide` `grid` and `layout`
2022-01-22 17:25:21 +02:00

37 lines
665 B
Bash
Executable file

#!/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