From f89ca3f235c504176d1e77501cee6902b8b2d8ee Mon Sep 17 00:00:00 2001 From: Dlurak <84224239+Dlurak@users.noreply.github.com> Date: Sun, 22 Sep 2024 12:04:29 +0200 Subject: [PATCH] Update the README --- README.md | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ src/cli/init.rs | 15 +++++++++++ 2 files changed, 83 insertions(+) create mode 100644 src/cli/init.rs diff --git a/README.md b/README.md index 0811acd..efe582d 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,74 @@ Projects combine directories and templates. You can specify a template to use wi Moxide is licensed under the GPL. +## Scripting + +It is easy and recommended to use moxide in shell scripts. +Here is the one I recommend: + +```sh +#!/bin/bash + +project_emoji="🚀" +template_emoji="🛠️" +directory_emoji="📁" + +if [ "$1" == "rofi" ]; then + selection_tool="rofi" +else + selection_tool="fzf" +fi + +fzf_colors="--color=bg+:#313244,bg:#1e1e2e,spinner:#f5e0dc,hl:#f38ba8 \ + --color=fg:#cdd6f4,header:#f38ba8,info:#cba6f7,pointer:#f5e0dc \ + --color=marker:#b4befe,fg+:#cdd6f4,prompt:#cba6f7,hl+:#f38ba8 \ + --color=selected-bg:#45475a" + +list=$(moxide list \ + --format-project "$project_emoji {}"\ + --format-template "$template_emoji {}"\ + --format-directory "$directory_emoji {}" +) + +case "$selection_tool" in + "rofi") + value=$(echo "$list" | rofi -dmenu -p " Tmux"); + ;; + *) + value=$(echo "$list" | \ + fzf \ + --no-sort \ + --layout reverse \ + --border rounded \ + --border-label "Moxide Sessions" \ + --no-scrollbar \ + --prompt "✨ " \ + --pointer "👉" \ + $fzf_colors + ) + ;; +esac + +emoji="${value:0:1}" +name="${value:2}" + +case "$emoji" in + $project_emoji) + moxide project start "$name" + ;; + $template_emoji) + moxide template start "$name" + ;; + $directory_emoji) + moxide dir start "$name" + ;; +esac +``` +Then you can bind that into a tmux popup: +```tmux +bind-key s display-popup -B -E -w 40% -h 12 "~/Dotfiles/scripts/shell/moxide.sh" +``` + ## Similar Projects If you are exploring alternatives, you might find these similar tools useful: diff --git a/src/cli/init.rs b/src/cli/init.rs new file mode 100644 index 0000000..82ba71d --- /dev/null +++ b/src/cli/init.rs @@ -0,0 +1,15 @@ +use clap::Parser; + +#[derive(Parser, Debug)] +pub struct InitCli { + #[arg(long, alias = "gen-config", default_value_t = false)] + pub config: bool, + #[arg( + long, + alias = "gen-completion", + alias = "gen-comp", + alias = "gen-complete", + default_value_t = false + )] + pub completion: bool, +}