feat: add init.sh
This commit is contained in:
+12
-4
@@ -24,11 +24,19 @@ dotfile_help_requested "${1:-}" && dotfile_show_help
|
||||
set -euo pipefail
|
||||
|
||||
echo 'Init git config'
|
||||
src=$HOME/.gitconfig
|
||||
if [ -f "$src" ]; then
|
||||
mv "$src" "$src.bak"
|
||||
src="$HOME/.gitconfig"
|
||||
target="$HOME/.dotfile/git/.gitconfig"
|
||||
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/git/.gitconfig" "$src"
|
||||
|
||||
chmod +x "$HOME/.dotfile/git/git-credential.sh"
|
||||
# 兼容旧路径:若仍存在则保持可执行
|
||||
|
||||
+17
-5
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user