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.
This commit is contained in:
Kenneth Benzie 2024-04-13 16:28:55 +01:00
parent 896a9e09d3
commit 7fd94d4f10
2 changed files with 40 additions and 25 deletions

40
install.sh Executable file
View File

@ -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

View File

@ -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