Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions scripts/handle_tmux_automatic_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,25 @@ is_systemd() {
[ $(ps -o comm= -p1) == 'systemd' ]
}

# Only manage the systemd unit either if it is not already installed, or if it
# was installed by us (as signified by the magic comment)
should_manage_systemd_unit() {
[ ! -f ${systemd_unit_file_path} ] \
&& \
systemctl cat --user ${systemd_service_name} | grep -q 'managed-by:tmux-continuum'
}

main() {
if is_tmux_automatic_start_enabled; then
if is_osx; then
"$CURRENT_DIR/handle_tmux_automatic_start/osx_enable.sh"
elif is_systemd; then
elif is_systemd && should_manage_systemd_unit; then
"$CURRENT_DIR/handle_tmux_automatic_start/systemd_enable.sh"
fi
else
if is_osx; then
"$CURRENT_DIR/handle_tmux_automatic_start/osx_disable.sh"
elif is_systemd; then
elif is_systemd && should_manage_systemd_unit; then
"$CURRENT_DIR/handle_tmux_automatic_start/systemd_disable.sh"
fi
fi
Expand Down
3 changes: 3 additions & 0 deletions scripts/handle_tmux_automatic_start/systemd_enable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ template() {
local tmux_path="$(command -v tmux)"

read -r -d '' content <<-EOF
#managed-by:tmux-continuum
# This file is managed by the tmux-continuum plugin. Manual changes
# will be overridden.
[Unit]
Description=tmux default session (detached)
Documentation=man:tmux(1)
Expand Down