mirror of
https://github.com/jimeh/tmuxifier.git
synced 2026-02-19 09:56:39 +00:00
Additionally, also fix a bug when creating a window, where as if the session name was the same as a window that already existed, it would fail, accidentally using the window rather than the session at a target.
30 lines
706 B
Bash
Executable File
30 lines
706 B
Bash
Executable File
#! /usr/bin/env bash
|
|
set -e
|
|
[ -n "$TMUXIFIER_DEBUG" ] && set -x
|
|
|
|
if [ -z "$1" ]; then
|
|
echo "$(tmuxifier-help new-window)" >&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
|
|
|
|
content="$(cat "$template")"
|
|
echo "${content/\{\{WINDOW_NAME\}\}/$layout_name}" > "$layout_file"
|
|
exec "$EDITOR" "$layout_file"
|