From 7fd94d4f107cf851c634c75e890c34cd774a1d9d Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Sat, 13 Apr 2024 16:28:55 +0100 Subject: [PATCH] Enable standalone install with install.sh Move away from being dependant on Ansible task.yaml config setup and move all login into install.sh to support installing tmux config just by cloning and running the script. --- install.sh | 40 ++++++++++++++++++++++++++++++++++++++++ tasks.yaml | 25 ------------------------- 2 files changed, 40 insertions(+), 25 deletions(-) create mode 100755 install.sh delete mode 100644 tasks.yaml diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..9dbeba3 --- /dev/null +++ b/install.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +if [ ! -d ~/.local/share/tmux/layouts ]; then + mkdir -p ~/.local/share/tmux/layouts + echo changed created layouts directory +fi + +declare -A symlinks=( + [~/.config/tmux/tmux.conf]=~/.tmux.conf +) + +layouts=( + session-local + session-main + session-visor + window-auto + window-tall + window-wide-left + window-wide-right +) +for layout in ${layouts[@]}; do + symlinks[~/.config/tmux/layouts/$layout]=~/.local/share/tmux/layouts/$layout +done + +for source in ${!symlinks[@]}; do + dest=${symlinks[${source}]} + if [ -L $dest ]; then + target=`readlink $dest` + if [ "$target" != "$source" ]; then + rm $dest + ln -s $source $dest + echo changed replace incorrect symlink $dest + fi + elif [ -f $dest ]; then + error symlink failed $dest exists but is a regular file + else + ln -s $source $dest + echo changed created symlink $dest + fi +done diff --git a/tasks.yaml b/tasks.yaml deleted file mode 100644 index 56c3afa..0000000 --- a/tasks.yaml +++ /dev/null @@ -1,25 +0,0 @@ ---- -- name: tmux create layouts directory - file: - state: directory - dest: ~/.local/share/tmux/layouts - -- name: tmux create config symbolic link - file: - state: link - src: ~/.config/tmux/tmux.conf - dest: ~/.tmux.conf - -- name: tmux create layout symbolic links - file: - state: link - src: '~/.config/tmux/layouts/{{item}}' - dest: '~/.local/share/tmux/layouts/{{item}}' - with_items: - - session-local - - session-main - - session-visor - - window-auto - - window-tall - - window-wide-left - - window-wide-right