Crates.io | tmux-menu |
lib.rs | tmux-menu |
version | 0.1.10 |
source | src |
created_at | 2023-03-02 05:28:58.867659 |
updated_at | 2024-02-14 02:28:59.534646 |
description | Easy configuration of tmux display-menu with yaml |
homepage | |
repository | https://github.com/Ja-sonYun/tmux-easy-menu |
max_upload_size | |
id | 798656 |
size | 41,624 |
cargo install tmux-menu
To see more actual config files, checkout ./examples
folder.
# On tmux.conf, add below line.
#
# bind-key k run-shell "tmux-menu show --menu $HOME/tmux-menu/examples/menu.yaml --working_dir #{pane_current_path}"
#
# =============================
#
title: "..."
border: "rounded" # Optional, possible options are: single, rounded, double, heavy, simple, padded, none
position:
x: ...
y: ...
items:
- Seperate: {} # Draw seperate line
- NoDim: # Add row, but unselectable
name: "..."
- Menu: # Add selectable row
name: "..."
shortcut: "..." # Optional
# ------------------
# You can define next_menu or command
next_menu: "..." # Show this menu when this row selected
# ... OR
command: "command %%KEY%% --cwd %%PWD" # Run command, %%PWD will replaced with cwd
inputs:
- KEY # This input will be replaced with '%%KEY%%' on command
# ------------------
background: false # Run command in background, popup will closed immediately
close_after_command: true # Close popup after command exited. if false, you should type <C-c> to close popup.
border: none # Select popup border type, optional, possible options are: single, rounded, double, heavy, simple, padded, none
session: false # Run commmand in new session. Useful for long running command. To hide popup while command running, use <C-d> to detach and close.
session_name: name # Session name, which will be used if session is true. This must be unique.
position:
x: ...
y: ...
w: ...
h: ...
Below example will show running brew services on display-menu, and restart it if clicked.
#!/bin/bash
# generate_brew_services_restart_menu.sh
TEMP_MENU_FILE="/tmp/temp_menu.yaml"
rm -f $TEMP_MENU_FILE
cat > $TEMP_MENU_FILE << EOM
title: " brew services "
items:
- Seperate: {}
- NoDim:
name: " Running services "
- NoDim:
name: " (select to restart) "
- Seperate: {}
EOM
brew services list | while read line
do
program=$(echo $line | awk '{print $1}')
status=$(echo $line | awk '{print $2}')
if [ "$status" == "started" ]; then
cat >> $TEMP_MENU_FILE <<- EOM
- Menu:
name: "$program"
shortcut: ".."
command: "brew services restart $program"
background: true
EOM
fi
done
tmux-menu show --menu $TEMP_MENU_FILE
rm -f $TEMP_MENU_FILE
and add menu item as below
- Menu:
name: "restart brew services"
shortcut: b
command: "$PATH_TO_SCRIPT/generate_brew_services_restart_menu.sh"
background: true