feat: add init.sh

This commit is contained in:
2026-07-25 21:02:07 +08:00
parent db8a531b92
commit c5d99958d4
3 changed files with 122 additions and 9 deletions
+17 -5
View File
@@ -23,11 +23,19 @@ dotfile_help_requested "${1:-}" && dotfile_show_help
set -euo pipefail
echo 'Init tmux config'
src=$HOME/.tmux.conf
if [ -e "$src" ]; then
mv "$src" "$src.bak"
src="$HOME/.tmux.conf"
target="$HOME/.dotfile/tmux/.tmux.conf"
if [ -L "$src" ] && [ "$(readlink "$src")" = "$target" ]; then
echo " $src already links to dotfile config, skip"
else
if [ -e "$src" ] || [ -L "$src" ]; then
backup="${src}.backup.$(date +%Y%m%d%H%M%S)"
mv "$src" "$backup"
echo " Backed up existing config: $backup"
fi
ln -s "$target" "$src"
echo " Linked: $src -> $target"
fi
ln -s "$HOME/.dotfile/tmux/.tmux.conf" "$src"
echo 'Install tpm'
if [ ! -e ~/.tmux/plugins/tpm ]; then
@@ -38,4 +46,8 @@ echo 'Install tmux plugin by tpm'
"$HOME/.tmux/plugins/tpm/bin/install_plugins"
echo 'Reload tmux'
tmux source ~/.tmux.conf
if tmux list-sessions >/dev/null 2>&1; then
tmux source-file "$src"
else
echo ' No running tmux server, config will be loaded when tmux starts'
fi