Last active
August 24, 2025 18:05
-
-
Save ryancheley/f5d66b0eefd4b3956cf5068f3a40002d to your computer and use it in GitHub Desktop.
Fish and Atuin Setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e # Exit on any error | |
| echo "Starting system setup..." | |
| # Update system | |
| echo "Updating system packages..." | |
| sudo apt update && sudo apt upgrade -y | |
| # Install basic packages | |
| echo "Installing basic packages..." | |
| packages_to_install="" | |
| for package in fish curl; do | |
| if ! dpkg -l | grep -q "^ii $package "; then | |
| packages_to_install="$packages_to_install $package" | |
| fi | |
| done | |
| if [ -n "$packages_to_install" ]; then | |
| echo "Installing:$packages_to_install" | |
| sudo apt install -y $packages_to_install | |
| else | |
| echo "All basic packages already installed" | |
| fi | |
| # Check and install GitHub CLI | |
| if ! command -v gh &> /dev/null; then | |
| echo "Installing GitHub CLI..." | |
| sudo apt install -y gh | |
| else | |
| echo "GitHub CLI already installed: $(gh --version | head -1)" | |
| fi | |
| # Simplified GitHub authentication check | |
| echo "Checking GitHub authentication..." | |
| auth_needed=true | |
| # Test authentication with a simple repository access that doesn't require specific permissions | |
| set +e | |
| gh repo view dotfiles --json name > /dev/null 2>&1 | |
| repo_check=$? | |
| set -e | |
| if [ $repo_check -eq 0 ]; then | |
| echo "GitHub authentication working - can access repositories" | |
| auth_needed=false | |
| else | |
| echo "GitHub authentication needed or repository access failed" | |
| fi | |
| # Authenticate if needed | |
| if [ "$auth_needed" = true ]; then | |
| if [ -n "$GITHUB_TOKEN" ]; then | |
| echo "Authenticating to GitHub with token..." | |
| set +e | |
| echo "$GITHUB_TOKEN" | gh auth login --with-token | |
| auth_result=$? | |
| set -e | |
| if [ $auth_result -ne 0 ]; then | |
| echo "Token authentication failed. Please check your GITHUB_TOKEN" | |
| exit 1 | |
| fi | |
| else | |
| echo "No GITHUB_TOKEN found. Please authenticate manually:" | |
| gh auth login | |
| fi | |
| fi | |
| # Check if fish is already the default shell | |
| current_shell=$(basename "$SHELL") | |
| if [ "$current_shell" != "fish" ]; then | |
| echo "Changing default shell to fish..." | |
| chsh -s $(which fish) | |
| else | |
| echo "Fish is already the default shell" | |
| fi | |
| # Check and install starship | |
| if ! command -v starship &> /dev/null; then | |
| echo "Installing starship..." | |
| curl -sS https://starship.rs/install.sh | sh -s -- -y | |
| else | |
| echo "Starship already installed: $(starship --version)" | |
| fi | |
| # Check and install atuin | |
| if ! command -v atuin &> /dev/null; then | |
| echo "Installing atuin..." | |
| curl --proto '=https' --tlsv1.2 -LsSf https://setup.atuin.sh | sh | |
| else | |
| echo "Atuin already installed: $(atuin --version)" | |
| fi | |
| # Setup fish directories | |
| mkdir -p ~/.local/bin | |
| touch ~/.local/bin/env.fish | |
| # Handle dotfiles cloning and config backup | |
| if [ -d "dotfiles" ]; then | |
| echo "Dotfiles directory already exists, updating..." | |
| cd dotfiles | |
| gh auth setup-git | |
| git pull | |
| cd .. | |
| else | |
| echo "Cloning dotfiles..." | |
| gh repo clone dotfiles | |
| fi | |
| # Backup existing config directories only if they exist and aren't already backed up | |
| backup_config() { | |
| local config_dir="$1" | |
| local config_path="$HOME/.config/$config_dir" | |
| local backup_path="$config_path.old" | |
| if [ -d "$config_path" ] && [ ! -d "$backup_path" ]; then | |
| echo "Backing up existing $config_dir config..." | |
| mv "$config_path" "$backup_path" | |
| elif [ -d "$backup_path" ]; then | |
| echo "Backup for $config_dir already exists, removing current config..." | |
| rm -rf "$config_path" 2>/dev/null || true | |
| fi | |
| } | |
| backup_config "fish" | |
| backup_config "atuin" | |
| # Run setup file | |
| echo "Running dotfiles setup..." | |
| cd dotfiles | |
| ./setup.sh | |
| cd .. | |
| # Clean up old config directories only if they exist | |
| cleanup_backup() { | |
| local backup_path="$HOME/.config/$1.old" | |
| if [ -d "$backup_path" ]; then | |
| echo "Cleaning up old $1 config backup..." | |
| rm -rf "$backup_path" | |
| fi | |
| } | |
| cleanup_backup "fish" | |
| cleanup_backup "atuin" | |
| echo "Setup completed successfully!" | |
| echo "Please log out and log back in for fish shell to take effect, or run 'exec fish' manually." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment