mirror of
https://github.com/jimeh/tmuxifier.git
synced 2026-02-19 09:56:39 +00:00
Add "new" and "edit" commands
This commit is contained in:
29
libexec/tmuxifier-edit-session
Executable file
29
libexec/tmuxifier-edit-session
Executable file
@@ -0,0 +1,29 @@
|
||||
#! /usr/bin/env bash
|
||||
set -e
|
||||
[ -n "$TMUXIFIER_DEBUG" ] && set -x
|
||||
|
||||
# Provide tmuxifier completions
|
||||
if [ "$1" == "--complete" ]; then
|
||||
for item in $(tmuxifier-list-sessions); do
|
||||
echo "$item"
|
||||
done
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "usage: tmuxifier edit-session <layout_name>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
layout_name="$1"
|
||||
layout_file="$TMUXIFIER_LAYOUT_PATH/${layout_name}.session.sh"
|
||||
|
||||
if [ ! -f "$layout_file" ]; then
|
||||
echo "tmuxifier: session layout '$layout_name' does not exist." >&2
|
||||
echo "" >&2
|
||||
echo "You can create it with:" >&2
|
||||
echo " tmuxifier new-session $layout_name" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec "$EDITOR" "$layout_file"
|
||||
29
libexec/tmuxifier-edit-window
Executable file
29
libexec/tmuxifier-edit-window
Executable file
@@ -0,0 +1,29 @@
|
||||
#! /usr/bin/env bash
|
||||
set -e
|
||||
[ -n "$TMUXIFIER_DEBUG" ] && set -x
|
||||
|
||||
# Provide tmuxifier completions
|
||||
if [ "$1" == "--complete" ]; then
|
||||
for item in $(tmuxifier-list-windows); do
|
||||
echo "$item"
|
||||
done
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "usage: tmuxifier edit-window <layout_name>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
layout_name="$1"
|
||||
layout_file="$TMUXIFIER_LAYOUT_PATH/${layout_name}.window.sh"
|
||||
|
||||
if [ ! -f "$layout_file" ]; then
|
||||
echo "tmuxifier: window layout '$layout_name' does not exist." >&2
|
||||
echo "" >&2
|
||||
echo "You can create it with:" >&2
|
||||
echo " tmuxifier new-window $layout_name" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec "$EDITOR" "$layout_file"
|
||||
@@ -12,6 +12,10 @@ Some useful tmuxifier commands are:
|
||||
list List all session and window layouts.
|
||||
list-sessions List session layouts.
|
||||
list-windows List window layouts.
|
||||
new-session Create new session layout and open it with \`$EDITOR\`.
|
||||
new-window Create new window layout and open it with \`$EDITOR\`.
|
||||
edit-session Edit specified session layout with \`$EDITOR\`.
|
||||
edit-window Edit specified window layout with \`$EDITOR\`.
|
||||
commands List all tmuxifier commands.
|
||||
|
||||
See 'tmuxifier help <command>' for information on a specific command."
|
||||
@@ -19,7 +23,7 @@ See 'tmuxifier help <command>' for information on a specific command."
|
||||
* )
|
||||
command_path="$(command -v "tmuxifier-$1" || true)"
|
||||
if [ -n "$command_path" ]; then
|
||||
echo "Sorry, the \`$1' command isn't documented yet."
|
||||
echo "Sorry, the '$1' command isn't documented yet."
|
||||
echo
|
||||
echo "You can view the command's source here:"
|
||||
echo "$command_path"
|
||||
|
||||
28
libexec/tmuxifier-new-session
Executable file
28
libexec/tmuxifier-new-session
Executable file
@@ -0,0 +1,28 @@
|
||||
#! /usr/bin/env bash
|
||||
set -e
|
||||
[ -n "$TMUXIFIER_DEBUG" ] && set -x
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "usage: tmuxifier new-session <layout_name>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
layout_name="$1"
|
||||
layout_file="$TMUXIFIER_LAYOUT_PATH/${layout_name}.session.sh"
|
||||
template="$TMUXIFIER/templates/session.sh"
|
||||
|
||||
if [ ! -f "$template" ]; then
|
||||
echo "tmuxifier: session layout template not found: $template" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f "$layout_file" ]; then
|
||||
echo "session layout '$layout_name' already exists." >&2
|
||||
echo "" >&2
|
||||
echo "You can edit it with:" >&2
|
||||
echo " tmuxifier edit-session $layout_name" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp "$template" "$layout_file"
|
||||
exec "$EDITOR" "$layout_file"
|
||||
28
libexec/tmuxifier-new-window
Executable file
28
libexec/tmuxifier-new-window
Executable file
@@ -0,0 +1,28 @@
|
||||
#! /usr/bin/env bash
|
||||
set -e
|
||||
[ -n "$TMUXIFIER_DEBUG" ] && set -x
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "usage: tmuxifier new-window <layout_name>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
layout_name="$1"
|
||||
layout_file="$TMUXIFIER_LAYOUT_PATH/${layout_name}.window.sh"
|
||||
template="$TMUXIFIER/templates/window.sh"
|
||||
|
||||
if [ ! -f "$template" ]; then
|
||||
echo "tmuxifier: window layout template not found: $template" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f "$layout_file" ]; then
|
||||
echo "window layout '$layout_name' already exists." >&2
|
||||
echo "" >&2
|
||||
echo "You can edit it with:" >&2
|
||||
echo " tmuxifier edit-window $layout_name" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp "$template" "$layout_file"
|
||||
exec "$EDITOR" "$layout_file"
|
||||
Reference in New Issue
Block a user