mirror of
https://github.com/tumillanino/miasma-os.git
synced 2026-04-11 07:15:31 +00:00
moved etc into usr folder
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
is_fzf-marks_enabled() {
|
||||
local fzf_marks_mode fzf_marks_file
|
||||
fzf_marks_file=$(get_fzf-marks_file)
|
||||
if [[ -e "${fzf_marks_file}" ]]; then
|
||||
fzf_marks_mode=$(tmux_option_or_fallback "@sessionx-fzf-marks-mode" "off")
|
||||
fi
|
||||
|
||||
if [[ "$fzf_marks_mode" != "on" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
is_fzf-marks_mark(){
|
||||
if $(echo "$@" | grep -q ' : ' 2>&1); then
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
get_fzf-marks_file() {
|
||||
echo "$(tmux_option_or_fallback "@sessionx-fzf-marks-file" "$HOME/.fzf-marks" | sed "s|~|$HOME|")"
|
||||
}
|
||||
|
||||
get_fzf-marks_mark() {
|
||||
local mark
|
||||
mark=$(echo "$@" | cut -d: -f1 | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$//')
|
||||
echo "$mark"
|
||||
}
|
||||
|
||||
get_fzf-marks_target() {
|
||||
local target
|
||||
target=$(echo "$@" | cut -d: -f2 | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$//')
|
||||
echo "$target"
|
||||
}
|
||||
|
||||
get_fzf-marks_keybind() {
|
||||
local keybind
|
||||
keybind="$(tmux_option_or_fallback "@sessionx-bind-fzf-marks" "ctrl-g")"
|
||||
echo "$keybind"
|
||||
}
|
||||
|
||||
load_fzf-marks_binding(){
|
||||
echo "$(get_fzf-marks_keybind):reload(cat $(get_fzf-marks_file))+change-preview(sed 's/.*: \(.*\)$/\1/' <<< {} | xargs $(tmux_option_or_fallback "@sessionx-ls-command" "ls"))"
|
||||
}
|
||||
51
files/system/usr/etc/skel/.tmux/plugins/tmux-sessionx/scripts/git-branch.sh
Executable file
51
files/system/usr/etc/skel/.tmux/plugins/tmux-sessionx/scripts/git-branch.sh
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
GIT_BRANCH_COLOR=$'\033[38;2;137;180;250m'
|
||||
GIT_BRANCH_RESET=$'\033[0m'
|
||||
GIT_BRANCH_ICON=""
|
||||
GIT_TAG_ICON=""
|
||||
|
||||
format_sessions_with_git_branch() {
|
||||
local sessions="$1"
|
||||
local -a session_list=()
|
||||
local -a ref_list=()
|
||||
local -a icon_list=()
|
||||
local max_len=0
|
||||
|
||||
while IFS= read -r session; do
|
||||
[[ -z "$session" ]] && continue
|
||||
session_list+=("$session")
|
||||
local pane_path
|
||||
pane_path=$(tmux list-panes -t "$session" -F '#{pane_current_path}' 2>/dev/null | head -1)
|
||||
local ref=""
|
||||
local icon="$GIT_BRANCH_ICON"
|
||||
if [[ -n "$pane_path" ]]; then
|
||||
ref=$(git -C "$pane_path" branch --show-current 2>/dev/null)
|
||||
if [[ -z "$ref" ]]; then
|
||||
ref=$(git -C "$pane_path" describe --tags --exact-match 2>/dev/null)
|
||||
[[ -n "$ref" ]] && icon="$GIT_TAG_ICON"
|
||||
fi
|
||||
fi
|
||||
ref_list+=("$ref")
|
||||
icon_list+=("$icon")
|
||||
local len=${#session}
|
||||
(( len > max_len )) && max_len=$len
|
||||
done <<< "$sessions"
|
||||
|
||||
for ((j=0; j<${#session_list[@]}; j++)); do
|
||||
local name="${session_list[$j]}"
|
||||
local ref="${ref_list[$j]}"
|
||||
local icon="${icon_list[$j]}"
|
||||
if [[ -n "$ref" ]]; then
|
||||
printf "%-${max_len}s ${GIT_BRANCH_COLOR}${icon} %s${GIT_BRANCH_RESET}\n" "$name" "$ref"
|
||||
else
|
||||
printf "%s\n" "$name"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
strip_git_branch_info() {
|
||||
local ESC
|
||||
ESC=$(printf '\033')
|
||||
echo "$1" | sed "s/${ESC}\[[0-9;]*m//g" | sed "s/[[:space:]]* .*//" | sed 's/[[:space:]]*$//'
|
||||
}
|
||||
141
files/system/usr/etc/skel/.tmux/plugins/tmux-sessionx/scripts/preview.sh
Executable file
141
files/system/usr/etc/skel/.tmux/plugins/tmux-sessionx/scripts/preview.sh
Executable file
@@ -0,0 +1,141 @@
|
||||
#!/usr/bin/env bash
|
||||
# Display preview of tmux windows/panes.
|
||||
# Meant for use in fzf preview.
|
||||
# Kudos:
|
||||
# https://stackoverflow.com/a/55247572/197789
|
||||
# https://github.com/petobens/dotfiles/blob/master/tmux/tmux_tree
|
||||
|
||||
single_mode() {
|
||||
# check if it's a custom directory
|
||||
if test -d "${1}"; then
|
||||
display_directory "${1}"
|
||||
return
|
||||
fi
|
||||
|
||||
session_name="${1}"
|
||||
if test "${DISPLAY_TMUXP}" -eq 1; then
|
||||
if $(tmux has-session -t "${session_name}" >&/dev/null); then
|
||||
:
|
||||
else
|
||||
tmuxp_conf="${HOME}/.tmuxp/${session_name}.yaml"
|
||||
if test -e "${tmuxp_conf}"; then
|
||||
cat "${tmuxp_conf}"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
display_session "${session_name}"
|
||||
}
|
||||
|
||||
tmux_option_or_fallback() {
|
||||
local option_value
|
||||
option_value="$(tmux show-option -gqv "$1")"
|
||||
if [ -z "$option_value" ]; then
|
||||
option_value="$2"
|
||||
fi
|
||||
echo "$option_value"
|
||||
}
|
||||
|
||||
# Display a directory using the configured ls command
|
||||
display_directory() {
|
||||
directory_name="${1}"
|
||||
ls_command=$(tmux_option_or_fallback "@sessionx-ls-command" "ls")
|
||||
eval "${ls_command} ${directory_name}"
|
||||
}
|
||||
|
||||
# Display a single sesssion
|
||||
display_session() {
|
||||
session_name="${1}"
|
||||
session_id=$(tmux ls -F '#{session_id}' -f "#{==:#{session_name},${session_name}}")
|
||||
if test -z "${session_id}"; then
|
||||
return 1
|
||||
fi
|
||||
tmux capture-pane -ep -t "${session_id}"
|
||||
}
|
||||
|
||||
window_mode() {
|
||||
args=($1)
|
||||
tmux capture-pane -ep -t "${args[0]}"
|
||||
}
|
||||
|
||||
# Display a full tree, with selected session highlighted.
|
||||
# If an session name is passed as an argument, highlight it
|
||||
# in the output.
|
||||
# This is the original tmux_tree script (see kudos).
|
||||
tree_mode() {
|
||||
highlight="${1}"
|
||||
icon=$(tmux_option_or_fallback "@sessionx-tree-icon" "")
|
||||
tmux ls -F'#{session_id}' | while read -r s; do
|
||||
S=$(tmux ls -F'#{session_id}#{session_name}: #{T:tree_mode_format}' | grep ^"$s")
|
||||
session_info=${S##$s}
|
||||
session_name=$(echo "$session_info" | cut -d ':' -f 1)
|
||||
if [[ -n "$highlight" ]] && [[ "$highlight" == "$session_name" ]]; then
|
||||
echo -e "\033[1;34m$session_info\033[0m"
|
||||
else
|
||||
echo -e "\033[1m$session_info\033[0m"
|
||||
fi
|
||||
# Display each window
|
||||
tmux lsw -t"$s" -F'#{window_id}' | while read -r w; do
|
||||
W=$(tmux lsw -t"$s" -F'#{window_id}#{T:tree_mode_format}' | grep ^"$w")
|
||||
echo " $icon ${W##$w}"
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat <<-END
|
||||
Usage: $0 [<options>] [<session_name>]
|
||||
|
||||
Options:
|
||||
-h Print help and exit.
|
||||
-p Display tmuxp configuration is session not running
|
||||
-t Display tree of sessions
|
||||
|
||||
A session name of "*Last*" is replaced with the client's last session.
|
||||
END
|
||||
# Note 'END' above most be fully left justified.
|
||||
}
|
||||
|
||||
# What are we displaying?
|
||||
# 'tree' == full tree of active sessions
|
||||
# 'single' == single session
|
||||
mode="single"
|
||||
|
||||
# In single mode, if session is not running, display
|
||||
# tmuxp configuration instead (if it exists)
|
||||
DISPLAY_TMUXP=0
|
||||
|
||||
while getopts ":hptw" opt; do
|
||||
case $opt in
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
p) DISPLAY_TMUXP=1 ;;
|
||||
t) mode="tree" ;;
|
||||
w) mode="window" ;;
|
||||
\?) echo "Invalid option: -$OPTARG" >&2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$CURRENT_DIR/git-branch.sh"
|
||||
SESSION=$(strip_git_branch_info "$1")
|
||||
|
||||
if test "${SESSION}" == '*Last*'; then
|
||||
SESSION=$(tmux display-message -p "#{client_last_session}")
|
||||
if test -z "${SESSION}"; then
|
||||
echo "No last session."
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
case "${mode}" in
|
||||
single) single_mode "${SESSION}" ;;
|
||||
tree) tree_mode "${SESSION}" ;;
|
||||
window) window_mode "${SESSION}" ;;
|
||||
*) echo "Unknown mode \"${mode}\"" ;;
|
||||
esac
|
||||
|
||||
exit $status
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$CURRENT_DIR/git-branch.sh"
|
||||
|
||||
CURRENT_SESSION=$(tmux display-message -p '#S')
|
||||
SESSIONS=$(tmux list-sessions | sed -E 's/:.*$//')
|
||||
|
||||
if [[ $(echo "$SESSIONS" | wc -l) -gt 1 ]]; then
|
||||
SESSIONS=$(echo "$SESSIONS" | grep -v "$CURRENT_SESSION")
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
GIT_BRANCH=$(tmux show-option -gqv "@sessionx-git-branch")
|
||||
if [[ "$GIT_BRANCH" == "on" ]]; then
|
||||
format_sessions_with_git_branch "$SESSIONS"
|
||||
else
|
||||
echo "$SESSIONS"
|
||||
fi
|
||||
@@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env bash
|
||||
# Git branch enrichment for tmux-sessionx.
|
||||
# Without args: outputs full enriched list to stdout (for fzf reload).
|
||||
# With a port arg: progressive reloads via fzf --listen API.
|
||||
|
||||
PORT="${1:-}"
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$CURRENT_DIR/git-branch.sh"
|
||||
|
||||
CURRENT="$(tmux display-message -p '#S')"
|
||||
|
||||
# Build sorted session list
|
||||
last_session=$(tmux display-message -p '#{client_last_session}')
|
||||
sessions=$(tmux list-sessions | sed -E 's/:.*$//' | grep -Fxv "$last_session")
|
||||
filtered_sessions=$(tmux show-option -gqv @sessionx-_filtered-sessions)
|
||||
if [[ -n "$filtered_sessions" ]]; then
|
||||
filtered_and_piped=$(echo "$filtered_sessions" | sed -E 's/,/|/g')
|
||||
sessions=$(echo "$sessions" | grep -Ev "$filtered_and_piped")
|
||||
fi
|
||||
sorted=$(echo -e "$sessions\n$last_session" | awk '!seen[$0]++')
|
||||
|
||||
filter_current=$(tmux show-option -gqv @sessionx-_filter-current)
|
||||
if [[ "$filter_current" == "true" ]]; then
|
||||
filtered=$(echo "$sorted" | grep -Fxv "$CURRENT")
|
||||
if [[ -n "$filtered" ]]; then
|
||||
sorted="$filtered"
|
||||
else
|
||||
sorted="$CURRENT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Custom paths (prepended before sessions)
|
||||
custom_prefix=""
|
||||
custom_paths=$(tmux show-option -gqv @sessionx-_custom-paths)
|
||||
if [[ -n "$custom_paths" ]]; then
|
||||
custom_path_subdirectories=$(tmux show-option -gqv @sessionx-_custom-paths-subdirectories)
|
||||
clean_paths=$(echo "$custom_paths" | sed -E 's/ *, */,/g' | sed -E 's/^ *//' | sed -E 's/ *$//' | sed -E 's/ /✗/g')
|
||||
if [[ "$custom_path_subdirectories" == "true" ]]; then
|
||||
paths=$(find ${clean_paths//,/ } -mindepth 1 -maxdepth 1 -type d)
|
||||
else
|
||||
paths=${clean_paths//,/ }
|
||||
fi
|
||||
for path in $paths; do
|
||||
if ! grep -q "$(basename "$path")" <<< "$sorted"; then
|
||||
custom_prefix+="$path"$'\n'
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ -z "$PORT" ]]; then
|
||||
# Stdout mode: output full enriched list at once
|
||||
[[ -n "$custom_prefix" ]] && printf "%s" "$custom_prefix"
|
||||
format_sessions_with_git_branch "$sorted"
|
||||
else
|
||||
# Progressive mode: resolve branches one by one, reload after each
|
||||
declare -a session_list=()
|
||||
declare -a ref_list=()
|
||||
declare -a icon_list=()
|
||||
while IFS= read -r session; do
|
||||
[[ -z "$session" ]] && continue
|
||||
session_list+=("$session")
|
||||
ref_list+=("")
|
||||
icon_list+=("$GIT_BRANCH_ICON")
|
||||
done <<< "$sorted"
|
||||
|
||||
max_len=0
|
||||
for name in "${session_list[@]}"; do
|
||||
len=${#name}
|
||||
(( len > max_len )) && max_len=$len
|
||||
done
|
||||
|
||||
TMPBASE="/tmp/sessionx-branches-$$"
|
||||
|
||||
output_current_state() {
|
||||
[[ -n "$custom_prefix" ]] && printf "%s" "$custom_prefix"
|
||||
for ((j=0; j<${#session_list[@]}; j++)); do
|
||||
name="${session_list[$j]}"
|
||||
ref="${ref_list[$j]}"
|
||||
icon="${icon_list[$j]}"
|
||||
if [[ -n "$ref" ]]; then
|
||||
printf "%-${max_len}s ${GIT_BRANCH_COLOR}${icon} %s${GIT_BRANCH_RESET}\n" "$name" "$ref"
|
||||
else
|
||||
printf "%s\n" "$name"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
sleep 0.1
|
||||
|
||||
for ((i=0; i<${#session_list[@]}; i++)); do
|
||||
session="${session_list[$i]}"
|
||||
pane_path=$(tmux list-panes -t "$session" -F '#{pane_current_path}' 2>/dev/null | head -1)
|
||||
ref=""
|
||||
icon="$GIT_BRANCH_ICON"
|
||||
if [[ -n "$pane_path" ]]; then
|
||||
ref=$(git -C "$pane_path" branch --show-current 2>/dev/null)
|
||||
if [[ -z "$ref" ]]; then
|
||||
ref=$(git -C "$pane_path" describe --tags --exact-match 2>/dev/null)
|
||||
[[ -n "$ref" ]] && icon="$GIT_TAG_ICON"
|
||||
fi
|
||||
fi
|
||||
ref_list[$i]="$ref"
|
||||
icon_list[$i]="$icon"
|
||||
|
||||
if [[ -n "$ref" ]]; then
|
||||
tmpfile="${TMPBASE}-${i}"
|
||||
output_current_state > "$tmpfile"
|
||||
curl -s -XPOST "localhost:$PORT" \
|
||||
-d "reload-sync(cat $tmpfile; rm -f $tmpfile)" 2>/dev/null || exit 0
|
||||
fi
|
||||
done
|
||||
fi
|
||||
159
files/system/usr/etc/skel/.tmux/plugins/tmux-sessionx/scripts/sessionx.sh
Executable file
159
files/system/usr/etc/skel/.tmux/plugins/tmux-sessionx/scripts/sessionx.sh
Executable file
@@ -0,0 +1,159 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
CURRENT="$(tmux display-message -p '#S')"
|
||||
Z_MODE="off"
|
||||
|
||||
source "$CURRENT_DIR/tmuxinator.sh"
|
||||
source "$CURRENT_DIR/fzf-marks.sh"
|
||||
source "$CURRENT_DIR/git-branch.sh"
|
||||
|
||||
get_sorted_sessions() {
|
||||
last_session=$(tmux display-message -p '#{client_last_session}')
|
||||
sessions=$(tmux list-sessions | sed -E 's/:.*$//' | grep -Fxv "$last_session")
|
||||
filtered_sessions=$(tmux show-option -gqv @sessionx-_filtered-sessions)
|
||||
if [[ -n "$filtered_sessions" ]]; then
|
||||
filtered_and_piped=$(echo "$filtered_sessions" | sed -E 's/,/|/g')
|
||||
sessions=$(echo "$sessions" | grep -Ev "$filtered_and_piped")
|
||||
fi
|
||||
local sorted
|
||||
sorted=$(echo -e "$sessions\n$last_session" | awk '!seen[$0]++')
|
||||
echo "$sorted"
|
||||
}
|
||||
|
||||
tmux_option_or_fallback() {
|
||||
local option_value
|
||||
option_value="$(tmux show-option -gqv "$1")"
|
||||
if [ -z "$option_value" ]; then
|
||||
option_value="$2"
|
||||
fi
|
||||
echo "$option_value"
|
||||
}
|
||||
|
||||
input() {
|
||||
default_window_mode=$(tmux show-option -gqv @sessionx-_window-mode)
|
||||
if [[ "$default_window_mode" == "on" ]]; then
|
||||
tmux list-windows -a -F '#{session_name}:#{window_index} #{window_name}'
|
||||
else
|
||||
filter_current_session=$(tmux show-option -gqv @sessionx-_filter-current)
|
||||
if [[ "$filter_current_session" == "true" ]]; then
|
||||
(get_sorted_sessions | grep -Fxv "$CURRENT") || echo "$CURRENT"
|
||||
else
|
||||
(get_sorted_sessions) || echo "$CURRENT"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
additional_input() {
|
||||
sessions=$(get_sorted_sessions)
|
||||
custom_paths=$(tmux show-option -gqv @sessionx-_custom-paths)
|
||||
custom_path_subdirectories=$(tmux show-option -gqv @sessionx-_custom-paths-subdirectories)
|
||||
if [[ -z "$custom_paths" ]]; then
|
||||
echo ""
|
||||
else
|
||||
clean_paths=$(echo "$custom_paths" | sed -E 's/ *, */,/g' | sed -E 's/^ *//' | sed -E 's/ *$//' | sed -E 's/ /✗/g')
|
||||
if [[ "$custom_path_subdirectories" == "true" ]]; then
|
||||
paths=$(find ${clean_paths//,/ } -mindepth 1 -maxdepth 1 -type d)
|
||||
else
|
||||
paths=${clean_paths//,/ }
|
||||
fi
|
||||
add_path() {
|
||||
local path=$1
|
||||
if ! grep -q "$(basename "$path")" <<< "$sessions"; then
|
||||
echo "$path"
|
||||
fi
|
||||
}
|
||||
export -f add_path
|
||||
printf "%s\n" "${paths//,/$IFS}" | xargs -n 1 -P 0 bash -c 'add_path "$@"' _
|
||||
fi
|
||||
}
|
||||
|
||||
handle_output() {
|
||||
set -- "$(strip_git_branch_info "$*")"
|
||||
if [ -d "$*" ]; then
|
||||
# No special handling because there isn't a window number or window name present
|
||||
# except in unlikely and contrived situations (e.g.
|
||||
# "/home/person/projects:0\ bash" could be a path on your filesystem.)
|
||||
target=$(echo "$@" | tr -d '\n')
|
||||
elif is_fzf-marks_mark "$@" ; then
|
||||
# Needs to run before session name mode
|
||||
mark=$(get_fzf-marks_mark "$@")
|
||||
target=$(get_fzf-marks_target "$@")
|
||||
elif echo "$@" | grep ':' >/dev/null 2>&1; then
|
||||
# Colon probably delimits session name and window number
|
||||
session_name=$(echo "$@" | cut -d: -f1)
|
||||
num=$(echo "$@" | cut -d: -f2 | cut -d' ' -f1)
|
||||
target=$(echo "${session_name}:${num}" | tr -d '\n')
|
||||
else
|
||||
# All tokens represent a session name
|
||||
target=$(echo "$@" | tr -d '\n')
|
||||
fi
|
||||
|
||||
if [[ -z "$target" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! tmux has-session -t="$target" 2>/dev/null; then
|
||||
if is_tmuxinator_enabled && is_tmuxinator_template "$target"; then
|
||||
tmuxinator start "$target"
|
||||
elif test -n "$mark"; then
|
||||
tmux new-session -ds "$mark" -c "$target"
|
||||
target="$mark"
|
||||
elif test -d "$target"; then
|
||||
d_target="$(basename "$target" | tr -d '.')"
|
||||
tmux new-session -ds $d_target -c "$target"
|
||||
target=$d_target
|
||||
else
|
||||
if [[ "$Z_MODE" == "on" ]]; then
|
||||
z_target=$(zoxide query "$target")
|
||||
tmux new-session -ds "$target" -c "$z_target" -n "$z_target"
|
||||
else
|
||||
tmux new-session -ds "$target"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
tmux switch-client -t "$target"
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
handle_input() {
|
||||
INPUT=$(input)
|
||||
ADDITIONAL_INPUT=$(additional_input)
|
||||
if [[ -n $ADDITIONAL_INPUT ]]; then
|
||||
INPUT="$(additional_input)\n$INPUT"
|
||||
fi
|
||||
bind_back=$(tmux show-option -gqv @sessionx-_bind-back)
|
||||
git_branch_mode=$(tmux show-option -gqv @sessionx-_git-branch)
|
||||
if [[ "$git_branch_mode" == "on" ]]; then
|
||||
BACK="$bind_back:reload(${CURRENT_DIR}/sessions_with_branches.sh)+change-preview(${CURRENT_DIR}/preview.sh {1})"
|
||||
else
|
||||
BACK="$bind_back:reload(echo -e \"${INPUT// /}\")+change-preview(${CURRENT_DIR}/preview.sh {1})"
|
||||
fi
|
||||
}
|
||||
|
||||
run_plugin() {
|
||||
Z_MODE=$(tmux_option_or_fallback "@sessionx-zoxide-mode" "off")
|
||||
eval $(tmux show-option -gqv @sessionx-_built-args)
|
||||
eval $(tmux show-option -gqv @sessionx-_built-fzf-opts)
|
||||
handle_input
|
||||
args+=(--bind "$BACK")
|
||||
|
||||
git_branch_mode=$(tmux show-option -gqv @sessionx-_git-branch)
|
||||
if [[ "$git_branch_mode" == "on" ]]; then
|
||||
FZF_LISTEN_PORT=$((RANDOM % 10000 + 20000))
|
||||
args+=(--listen "localhost:$FZF_LISTEN_PORT")
|
||||
args+=(--tiebreak=begin)
|
||||
"${CURRENT_DIR}/sessions_with_branches.sh" "$FZF_LISTEN_PORT" &
|
||||
fi
|
||||
|
||||
FZF_BUILTIN_TMUX=$(tmux show-option -gqv @sessionx-_fzf-builtin-tmux)
|
||||
if [[ "$FZF_BUILTIN_TMUX" == "on" ]]; then
|
||||
RESULT=$(echo -e "${INPUT}" | sed -E 's/✗/ /g' | fzf "${fzf_opts[@]}" "${args[@]}" | tail -n1)
|
||||
else
|
||||
RESULT=$(echo -e "${INPUT}" | sed -E 's/✗/ /g' | fzf-tmux "${fzf_opts[@]}" "${args[@]}" | tail -n1)
|
||||
fi
|
||||
}
|
||||
|
||||
run_plugin
|
||||
handle_output "$RESULT"
|
||||
21
files/system/usr/etc/skel/.tmux/plugins/tmux-sessionx/scripts/tmuxinator.sh
Executable file
21
files/system/usr/etc/skel/.tmux/plugins/tmux-sessionx/scripts/tmuxinator.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
is_tmuxinator_enabled() {
|
||||
local tmuxinator_mode=$(tmux_option_or_fallback "@sessionx-tmuxinator-mode" "off")
|
||||
|
||||
if [[ "$tmuxinator_mode" != "on" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
is_tmuxinator_template() {
|
||||
tmuxinator list --newline | grep -q "^$1$"
|
||||
}
|
||||
|
||||
load_tmuxinator_binding() {
|
||||
local keybind="$(tmux_option_or_fallback "@sessionx-bind-tmuxinator-list" "ctrl-/")"
|
||||
|
||||
printf "$keybind:reload(tmuxinator list --newline | sed '1d')+change-preview(cat ~/.config/tmuxinator/{}.yml 2>/dev/null)"
|
||||
}
|
||||
Reference in New Issue
Block a user