feat: init
8abeef7c
8 file(s) · +232 −0
| 1 | + | # history setup |
|
| 2 | + | HISTFILE=$HOME/.zhistory |
|
| 3 | + | SAVEHIST=1000 |
|
| 4 | + | HISTSIZE=999 |
|
| 5 | + | setopt share_history |
|
| 6 | + | setopt hist_expire_dups_first |
|
| 7 | + | setopt hist_ignore_dups |
|
| 8 | + | setopt hist_verify |
|
| 9 | + | ||
| 10 | + | # completion using arrow keys (based on history) |
|
| 11 | + | bindkey '^[[A' history-search-backward |
|
| 12 | + | bindkey '^[[B' history-search-forward |
|
| 13 | + | ||
| 14 | + | # completion using vim keys |
|
| 15 | + | bindkey '^k' history-search-backward |
|
| 16 | + | bindkey '^j' history-search-forward |
|
| 17 | + | ||
| 18 | + | source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh |
|
| 19 | + | source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh |
|
| 20 | + | ||
| 21 | + | alias ls="eza --icons=always" |
|
| 22 | + | ||
| 23 | + | eval "$(zoxide init zsh)" |
|
| 24 | + | ||
| 25 | + | alias cd="z" |
|
| 26 | + | ||
| 27 | + | eval "$(starship init zsh)" |
Binary file — no preview.
Binary file — no preview.
Binary file — no preview.
Binary file — no preview.
Binary file — no preview.
| 1 | + | font-family = CommitMono Nerd Font |
|
| 2 | + | font-family-bold = CommitMono Nerd Font |
|
| 3 | + | font-family-italic = CommitMono Nerd Font |
|
| 4 | + | font-family-bold-italic = CommitMono Nerd Font |
|
| 5 | + | font-size = 14 |
|
| 6 | + | ||
| 7 | + | theme = flexoki-dark |
|
| 8 | + | ||
| 9 | + | confirm-close-surface = false |
|
| 10 | + | clipboard-read = allow |
|
| 11 | + | clipboard-write = allow |
|
| 12 | + | mouse-hide-while-typing = true |
|
| 13 | + | window-padding-x = 6 |
|
| 14 | + | window-padding-balance = true |
|
| 15 | + | window-save-state = always |
|
| 16 | + | window-width = 85 |
|
| 17 | + | window-height = 30 |
|
| 18 | + | ||
| 19 | + | auto-update-channel = stable |
|
| 20 | + | click-repeat-interval = 500 |
| 1 | + | #!/bin/bash |
|
| 2 | + | ||
| 3 | + | # Terminal Setup - Opinionated terminal configuration installer |
|
| 4 | + | # Requires: Homebrew (https://brew.sh) |
|
| 5 | + | ||
| 6 | + | set -e # Exit on any error |
|
| 7 | + | ||
| 8 | + | # Colors for output |
|
| 9 | + | RED='\033[0;31m' |
|
| 10 | + | GREEN='\033[0;32m' |
|
| 11 | + | YELLOW='\033[1;33m' |
|
| 12 | + | BLUE='\033[0;34m' |
|
| 13 | + | NC='\033[0m' # No Color |
|
| 14 | + | ||
| 15 | + | # Function to print colored output |
|
| 16 | + | print_status() { |
|
| 17 | + | echo -e "${BLUE}[INFO]${NC} $1" |
|
| 18 | + | } |
|
| 19 | + | ||
| 20 | + | print_success() { |
|
| 21 | + | echo -e "${GREEN}[SUCCESS]${NC} $1" |
|
| 22 | + | } |
|
| 23 | + | ||
| 24 | + | print_warning() { |
|
| 25 | + | echo -e "${YELLOW}[WARNING]${NC} $1" |
|
| 26 | + | } |
|
| 27 | + | ||
| 28 | + | print_error() { |
|
| 29 | + | echo -e "${RED}[ERROR]${NC} $1" |
|
| 30 | + | } |
|
| 31 | + | ||
| 32 | + | # Check if Homebrew is installed |
|
| 33 | + | check_homebrew() { |
|
| 34 | + | if ! command -v brew &> /dev/null; then |
|
| 35 | + | print_error "Homebrew is not installed. Please install it first:" |
|
| 36 | + | print_error "https://brew.sh" |
|
| 37 | + | exit 1 |
|
| 38 | + | fi |
|
| 39 | + | print_success "Homebrew found" |
|
| 40 | + | } |
|
| 41 | + | ||
| 42 | + | # Install packages via Homebrew |
|
| 43 | + | install_packages() { |
|
| 44 | + | print_status "Installing packages via Homebrew..." |
|
| 45 | + | ||
| 46 | + | local packages=( |
|
| 47 | + | "zsh" |
|
| 48 | + | "zsh-autosuggestions" |
|
| 49 | + | "zsh-syntax-highlighting" |
|
| 50 | + | "starship" |
|
| 51 | + | "eza" |
|
| 52 | + | "zoxide" |
|
| 53 | + | ) |
|
| 54 | + | ||
| 55 | + | local cask_packages=( |
|
| 56 | + | "ghostty" |
|
| 57 | + | ) |
|
| 58 | + | ||
| 59 | + | # Install regular packages |
|
| 60 | + | for package in "${packages[@]}"; do |
|
| 61 | + | print_status "Installing $package..." |
|
| 62 | + | if brew list "$package" &>/dev/null; then |
|
| 63 | + | print_warning "$package is already installed" |
|
| 64 | + | else |
|
| 65 | + | brew install "$package" |
|
| 66 | + | print_success "Installed $package" |
|
| 67 | + | fi |
|
| 68 | + | done |
|
| 69 | + | ||
| 70 | + | # Install cask packages |
|
| 71 | + | for package in "${cask_packages[@]}"; do |
|
| 72 | + | print_status "Installing $package (cask)..." |
|
| 73 | + | if brew list --cask "$package" &>/dev/null; then |
|
| 74 | + | print_warning "$package is already installed" |
|
| 75 | + | else |
|
| 76 | + | brew install --cask "$package" |
|
| 77 | + | print_success "Installed $package" |
|
| 78 | + | fi |
|
| 79 | + | done |
|
| 80 | + | } |
|
| 81 | + | ||
| 82 | + | # Backup existing config files |
|
| 83 | + | backup_configs() { |
|
| 84 | + | print_status "Backing up existing configuration files..." |
|
| 85 | + | ||
| 86 | + | local timestamp=$(date +%Y%m%d_%H%M%S) |
|
| 87 | + | local backup_dir="$HOME/.config_backup_$timestamp" |
|
| 88 | + | ||
| 89 | + | mkdir -p "$backup_dir" |
|
| 90 | + | ||
| 91 | + | if [ -f "$HOME/.zshrc" ]; then |
|
| 92 | + | cp "$HOME/.zshrc" "$backup_dir/" |
|
| 93 | + | print_success "Backed up .zshrc to $backup_dir" |
|
| 94 | + | fi |
|
| 95 | + | ||
| 96 | + | if [ -f "$HOME/.config/ghostty/config" ]; then |
|
| 97 | + | cp "$HOME/.config/ghostty/config" "$backup_dir/" |
|
| 98 | + | print_success "Backed up ghotty config to $backup_dir" |
|
| 99 | + | fi |
|
| 100 | + | ||
| 101 | + | if [ -f "$HOME/.config/starship.toml" ]; then |
|
| 102 | + | mkdir -p "$backup_dir/.config" |
|
| 103 | + | cp "$HOME/.config/starship.toml" "$backup_dir/.config/" |
|
| 104 | + | print_success "Backed up starship.toml to $backup_dir" |
|
| 105 | + | fi |
|
| 106 | + | } |
|
| 107 | + | ||
| 108 | + | # Copy configuration files from the repo |
|
| 109 | + | copy_configs() { |
|
| 110 | + | print_status "Copying configuration files..." |
|
| 111 | + | ||
| 112 | + | local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
|
| 113 | + | ||
| 114 | + | # Copy .zshrc |
|
| 115 | + | if [ -f "$script_dir/.zshrc" ]; then |
|
| 116 | + | cp "$script_dir/.zshrc" "$HOME/" |
|
| 117 | + | print_success "Copied .zshrc" |
|
| 118 | + | else |
|
| 119 | + | print_warning ".zshrc not found in repo" |
|
| 120 | + | fi |
|
| 121 | + | ||
| 122 | + | # Copy ghostty config |
|
| 123 | + | if [ -f "$script_dir/config" ]; then |
|
| 124 | + | mkdir -p "$HOME/.config/ghostty" |
|
| 125 | + | cp "$script_dir/config" "$HOME/.config/ghostty/" |
|
| 126 | + | print_success "Copied ghostty config" |
|
| 127 | + | else |
|
| 128 | + | print_warning "Ghostty config not found in repo" |
|
| 129 | + | fi |
|
| 130 | + | ||
| 131 | + | # Copy starship config |
|
| 132 | + | if [ -f "$script_dir/starship.toml" ]; then |
|
| 133 | + | mkdir -p "$HOME/.config" |
|
| 134 | + | cp "$script_dir/starship.toml" "$HOME/.config/" |
|
| 135 | + | print_success "Copied starship.toml" |
|
| 136 | + | else |
|
| 137 | + | print_warning "starship.toml not found in repo" |
|
| 138 | + | fi |
|
| 139 | + | } |
|
| 140 | + | ||
| 141 | + | # Set zsh as default shell |
|
| 142 | + | set_default_shell() { |
|
| 143 | + | local current_shell=$(echo $SHELL) |
|
| 144 | + | local zsh_path=$(which zsh) |
|
| 145 | + | ||
| 146 | + | if [ "$current_shell" != "$zsh_path" ]; then |
|
| 147 | + | print_status "Setting zsh as default shell..." |
|
| 148 | + | ||
| 149 | + | # Add zsh to /etc/shells if not present |
|
| 150 | + | if ! grep -q "$zsh_path" /etc/shells; then |
|
| 151 | + | echo "$zsh_path" | sudo tee -a /etc/shells |
|
| 152 | + | fi |
|
| 153 | + | ||
| 154 | + | # Change default shell |
|
| 155 | + | chsh -s "$zsh_path" |
|
| 156 | + | print_success "Default shell set to zsh" |
|
| 157 | + | print_warning "Please restart your terminal or run 'exec zsh' to use the new shell" |
|
| 158 | + | else |
|
| 159 | + | print_success "zsh is already the default shell" |
|
| 160 | + | fi |
|
| 161 | + | } |
|
| 162 | + | ||
| 163 | + | # Main installation function |
|
| 164 | + | main() { |
|
| 165 | + | echo "🌑 Darkmatter Setup Installer" |
|
| 166 | + | echo "==========================" |
|
| 167 | + | echo |
|
| 168 | + | ||
| 169 | + | check_homebrew |
|
| 170 | + | install_packages |
|
| 171 | + | backup_configs |
|
| 172 | + | copy_configs |
|
| 173 | + | set_default_shell |
|
| 174 | + | ||
| 175 | + | echo |
|
| 176 | + | print_success "Installation complete! 🌌" |
|
| 177 | + | echo |
|
| 178 | + | print_status "Next steps:" |
|
| 179 | + | echo " 1. Restart your terminal or run: exec zsh" |
|
| 180 | + | echo " 2. Open Ghostty to use your new terminal setup" |
|
| 181 | + | echo " 3. Enjoy your opinionated terminal experience!" |
|
| 182 | + | } |
|
| 183 | + | ||
| 184 | + | # Run main function |
|
| 185 | + | main "$@" |