-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·36 lines (29 loc) · 1.09 KB
/
install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# Get the current shell
# current_shell=$(ps -p $$ -ocomm=)
current_shell=$(basename "$SHELL")
# Check if the first argument is passed, otherwise set it to 'install'
action=${1:-install}
# Get the directory of the script to run the appropriate script
dotfiles=$(dirname "$(realpath "$0")")
mkdir -p "$dotfiles/bak"
# Update the DOTROOT variable in the zshrc file
if [ -f "$dotfiles/zshrc" ]; then
sed -i "s|^export DOTROOT=.*|export DOTROOT=\"$dotfiles\"|" "$dotfiles/zshrc"
fi
# Update the DOTROOT variable in the bashrc file
if [ -f "$dotfiles/bashrc" ]; then
sed -i "s|^export DOTROOT=.*|export DOTROOT=\"$dotfiles\"|" "$dotfiles/bashrc"
# Run the appropriate script based on the current shell
case $current_shell in
*bash|*zsh)
echo "Detected $current_shell shell. Running install_bash.sh with argument '$action'..."
$current_shell "$dotfiles/bin/install_bashdots" "$action"
;;
*)
echo "Detected $current_shell shell. Running install_posix.sh with argument '$action'..."
$current_shell "$dotfiles/bin/install_posixdots" "$action"
;;
esac
fi
exec "${SHELL}"