Fix HUD behavior and installer host checks
This commit is contained in:
80
install.sh
80
install.sh
@@ -49,13 +49,20 @@ command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
require_command() {
|
||||
command_name=$1
|
||||
is_macos() {
|
||||
[ "$(uname -s)" = "Darwin" ]
|
||||
}
|
||||
|
||||
if ! command_exists "$command_name"; then
|
||||
error "$command_name is required but not installed. Install it first via your package manager."
|
||||
exit 1
|
||||
current_host_name() {
|
||||
if is_macos && command_exists scutil; then
|
||||
scutil --get LocalHostName 2>/dev/null && return
|
||||
fi
|
||||
|
||||
hostname -s 2>/dev/null || hostname
|
||||
}
|
||||
|
||||
is_studio_host() {
|
||||
[ "$(current_host_name)" = "studio" ]
|
||||
}
|
||||
|
||||
error() {
|
||||
@@ -88,21 +95,16 @@ setup_color() {
|
||||
apply_dotfiles() {
|
||||
echo "${BLUE}Applying dotfiles...${RESET}"
|
||||
|
||||
require_command lsd
|
||||
require_command tmux
|
||||
require_command nvim
|
||||
require_command rg
|
||||
|
||||
remove_legacy_dotfile "$HOME/.vimrc"
|
||||
link_dotfile "$DOTFILES_DIR/.zshrc" "$HOME/.zshrc"
|
||||
link_dotfile "$DOTFILES_DIR/.zprofile" "$HOME/.zprofile"
|
||||
link_dotfile "$DOTFILES_DIR/.gitconfig" "$HOME/.gitconfig"
|
||||
link_dotfile "$DOTFILES_DIR/.p10k.zsh" "$HOME/.p10k.zsh"
|
||||
mkdir -p "$HOME/.config"
|
||||
link_dotfile "$DOTFILES_DIR/kitty" "$HOME/.config/kitty"
|
||||
install_kitty_config
|
||||
link_dotfile "$DOTFILES_DIR/nvim" "$HOME/.config/nvim"
|
||||
link_dotfile "$DOTFILES_DIR/tmux" "$HOME/.config/tmux"
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
if is_macos; then
|
||||
install_karabiner_config
|
||||
fi
|
||||
install_fonts
|
||||
@@ -113,6 +115,24 @@ apply_dotfiles() {
|
||||
echo
|
||||
}
|
||||
|
||||
validate_prerequisites() {
|
||||
missing_commands=""
|
||||
|
||||
for command_name in git zsh lsd tmux nvim rg; do
|
||||
if ! command_exists "$command_name"; then
|
||||
if [ -n "$missing_commands" ]; then
|
||||
missing_commands="$missing_commands, "
|
||||
fi
|
||||
missing_commands="${missing_commands}${command_name}"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$missing_commands" ]; then
|
||||
error "required tools are missing: $missing_commands. Install them first via your package manager."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
remove_legacy_dotfile() {
|
||||
target_path=$1
|
||||
|
||||
@@ -162,6 +182,32 @@ link_dotfile() {
|
||||
echo "${GREEN}Linked $target_path -> $source_path${RESET}"
|
||||
}
|
||||
|
||||
ensure_directory() {
|
||||
target_path=$1
|
||||
|
||||
if [ -L "$target_path" ] || [ -f "$target_path" ]; then
|
||||
echo "${YELLOW}Removing existing $target_path${RESET}"
|
||||
rm -rf "$target_path"
|
||||
fi
|
||||
|
||||
mkdir -p "$target_path"
|
||||
}
|
||||
|
||||
install_kitty_config() {
|
||||
kitty_config_dir="$HOME/.config/kitty"
|
||||
|
||||
ensure_directory "$kitty_config_dir"
|
||||
link_dotfile "$DOTFILES_DIR/kitty/kitty.conf" "$kitty_config_dir/kitty.conf"
|
||||
link_dotfile "$DOTFILES_DIR/kitty/macos-launch-services-cmdline" "$kitty_config_dir/macos-launch-services-cmdline"
|
||||
|
||||
if is_studio_host; then
|
||||
link_dotfile "$DOTFILES_DIR/hosts/studio/kitty/quick-access-terminal.conf" "$kitty_config_dir/quick-access-terminal.conf"
|
||||
elif [ -L "$kitty_config_dir/quick-access-terminal.conf" ] || [ -e "$kitty_config_dir/quick-access-terminal.conf" ]; then
|
||||
echo "${YELLOW}Removing existing $kitty_config_dir/quick-access-terminal.conf${RESET}"
|
||||
rm -rf "$kitty_config_dir/quick-access-terminal.conf"
|
||||
fi
|
||||
}
|
||||
|
||||
install_karabiner_config() {
|
||||
mkdir -p "$HOME/.config/karabiner"
|
||||
link_dotfile "$DOTFILES_DIR/karabiner/karabiner.json" "$HOME/.config/karabiner/karabiner.json"
|
||||
@@ -171,7 +217,7 @@ install_karabiner_config() {
|
||||
install_kitty_icon() {
|
||||
icon_path="$DOTFILES_DIR/kitty/kitty.app.png"
|
||||
|
||||
if [ "$(uname -s)" != "Darwin" ]; then
|
||||
if ! is_macos; then
|
||||
return
|
||||
fi
|
||||
|
||||
@@ -199,7 +245,7 @@ install_kitty_icon() {
|
||||
}
|
||||
|
||||
install_fonts() {
|
||||
if [ "$(uname -s)" != "Darwin" ]; then
|
||||
if ! is_macos; then
|
||||
return
|
||||
fi
|
||||
|
||||
@@ -383,11 +429,7 @@ main() {
|
||||
done
|
||||
|
||||
setup_color
|
||||
|
||||
if ! command_exists zsh; then
|
||||
echo "${YELLOW}Zsh is not installed.${RESET} Please install zsh first."
|
||||
exit 1
|
||||
fi
|
||||
validate_prerequisites
|
||||
|
||||
setup_ohmyzsh
|
||||
setup_shell
|
||||
|
||||
Reference in New Issue
Block a user