Simplify the logic of project lanucher
This commit is contained in:
parent
0c72fedeb8
commit
f58a088c43
4 changed files with 10 additions and 28 deletions
|
|
@ -175,8 +175,10 @@ cdf [pattern] # Find file/directory and cd to its location
|
||||||
|
|
||||||
#### Usage:
|
#### Usage:
|
||||||
```bash
|
```bash
|
||||||
proj # List all available projects
|
proj # List all available projects
|
||||||
nix-config # Launch nix-config project tmux session
|
proj nix-config # Launch nix-config project tmux session
|
||||||
|
proj blog # Launch blog project tmux session
|
||||||
|
proj homelab # Launch homelab project tmux session
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Window-Based Configuration:
|
#### Window-Based Configuration:
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@ let
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
projects = {
|
projects = {
|
||||||
nix-config = {
|
nix = {
|
||||||
session = "nix";
|
|
||||||
description = "Nix configuration";
|
description = "Nix configuration";
|
||||||
windows = [
|
windows = [
|
||||||
{
|
{
|
||||||
|
|
@ -20,7 +19,6 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
homelab = {
|
homelab = {
|
||||||
session = "homelab";
|
|
||||||
description = "Homelab Deployment";
|
description = "Homelab Deployment";
|
||||||
windows = [
|
windows = [
|
||||||
{
|
{
|
||||||
|
|
@ -34,7 +32,6 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
note = {
|
note = {
|
||||||
session = "note";
|
|
||||||
description = "Obsidian notes";
|
description = "Obsidian notes";
|
||||||
windows = [
|
windows = [
|
||||||
{
|
{
|
||||||
|
|
@ -48,7 +45,6 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
acapro = {
|
acapro = {
|
||||||
session = "aca-programs";
|
|
||||||
description = "Academic programs";
|
description = "Academic programs";
|
||||||
windows = [
|
windows = [
|
||||||
{
|
{
|
||||||
|
|
@ -62,7 +58,6 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
blog = {
|
blog = {
|
||||||
session = "blog";
|
|
||||||
description = "Personal blog project";
|
description = "Personal blog project";
|
||||||
windows = [
|
windows = [
|
||||||
{
|
{
|
||||||
|
|
@ -82,7 +77,6 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
homepage = {
|
homepage = {
|
||||||
session = "homepage";
|
|
||||||
description = "Personal Homepage";
|
description = "Personal Homepage";
|
||||||
windows = [
|
windows = [
|
||||||
{
|
{
|
||||||
|
|
@ -96,7 +90,6 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
mdshortcut = {
|
mdshortcut = {
|
||||||
session = "MDShortcut";
|
|
||||||
description = "Material design shortcut";
|
description = "Material design shortcut";
|
||||||
windows = [
|
windows = [
|
||||||
{
|
{
|
||||||
|
|
@ -117,7 +110,6 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
daki3c = {
|
daki3c = {
|
||||||
session = "DAKI3-C";
|
|
||||||
description = "DAKI3 course";
|
description = "DAKI3 course";
|
||||||
windows = [
|
windows = [
|
||||||
{
|
{
|
||||||
|
|
@ -145,7 +137,6 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
daki3g = {
|
daki3g = {
|
||||||
session = "DAKI3-G";
|
|
||||||
description = "DAKI3 group supervision";
|
description = "DAKI3 group supervision";
|
||||||
windows = [
|
windows = [
|
||||||
{
|
{
|
||||||
|
|
@ -159,7 +150,6 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
matmeet = {
|
matmeet = {
|
||||||
session = "MaterialMeet";
|
|
||||||
description = "Material Meeting Slides";
|
description = "Material Meeting Slides";
|
||||||
windows = [
|
windows = [
|
||||||
{
|
{
|
||||||
|
|
@ -173,7 +163,6 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
ddm = {
|
ddm = {
|
||||||
session = "DiffDisMatter";
|
|
||||||
description = "Inverse material design";
|
description = "Inverse material design";
|
||||||
windows = [
|
windows = [
|
||||||
{
|
{
|
||||||
|
|
@ -194,7 +183,6 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
misc = {
|
misc = {
|
||||||
session = "Misc";
|
|
||||||
description = "Temp misc project";
|
description = "Temp misc project";
|
||||||
windows = [
|
windows = [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -44,15 +44,7 @@ in
|
||||||
|
|
||||||
# Project shortcuts
|
# Project shortcuts
|
||||||
proj = "${projectLauncher}";
|
proj = "${projectLauncher}";
|
||||||
} // (
|
};
|
||||||
# Generate project aliases dynamically
|
|
||||||
builtins.listToAttrs (
|
|
||||||
builtins.map (projectName: {
|
|
||||||
name = projectName;
|
|
||||||
value = "${projectLauncher} ${projectName}";
|
|
||||||
}) (builtins.attrNames projectsConfig.projects)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
initContent = ''
|
initContent = ''
|
||||||
# Load Powerlevel10k theme
|
# Load Powerlevel10k theme
|
||||||
|
|
|
||||||
|
|
@ -47,10 +47,10 @@ if [ -z "$PROJECT_NAME" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Parse and display projects with descriptions
|
# Parse and display projects with descriptions
|
||||||
jq -r '.projects | to_entries[] | "\(.key)|\(.value.description)|\(.value.session)"' "$PROJECTS_JSON" 2>/dev/null | \
|
jq -r '.projects | to_entries[] | "\(.key)|\(.value.description)"' "$PROJECTS_JSON" 2>/dev/null | \
|
||||||
while IFS='|' read -r name desc session_name; do
|
while IFS='|' read -r name desc; do
|
||||||
# Check if session is running and format accordingly
|
# Check if session is running and format accordingly
|
||||||
if is_session_running "$session_name"; then
|
if is_session_running "$name"; then
|
||||||
printf " \033[1;32m%-12s\033[0m %s\033[1;32m • Running\033[0m\n" \
|
printf " \033[1;32m%-12s\033[0m %s\033[1;32m • Running\033[0m\n" \
|
||||||
"$name" "$desc"
|
"$name" "$desc"
|
||||||
else
|
else
|
||||||
|
|
@ -85,7 +85,7 @@ if [ "$PROJECT_CONFIG" = "null" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SESSION_NAME=$(echo "$PROJECT_CONFIG" | jq -r '.session')
|
SESSION_NAME="$PROJECT_NAME"
|
||||||
DESCRIPTION=$(echo "$PROJECT_CONFIG" | jq -r '.description // empty')
|
DESCRIPTION=$(echo "$PROJECT_CONFIG" | jq -r '.description // empty')
|
||||||
|
|
||||||
# Check if session already exists
|
# Check if session already exists
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue