mirror of
https://github.com/acedanger/dotfiles.git
synced 2025-12-05 22:30:13 -08:00
Enhance dotfiles setup with comprehensive installation scripts and package management
This commit is contained in:
27
.zshrc
27
.zshrc
@@ -51,6 +51,9 @@ plugins=(git zsh-autosuggestions zsh-syntax-highlighting docker docker-compose y
|
|||||||
export ZSH_COMPDUMP=$ZSH/cache/.zcompdump-$HOST
|
export ZSH_COMPDUMP=$ZSH/cache/.zcompdump-$HOST
|
||||||
source $ZSH/oh-my-zsh.sh
|
source $ZSH/oh-my-zsh.sh
|
||||||
|
|
||||||
|
# Initialize zoxide
|
||||||
|
eval "$(zoxide init zsh)"
|
||||||
|
|
||||||
# User configuration
|
# User configuration
|
||||||
# export MANPATH="/usr/local/man:$MANPATH"
|
# export MANPATH="/usr/local/man:$MANPATH"
|
||||||
|
|
||||||
@@ -72,6 +75,11 @@ source $ZSH/oh-my-zsh.sh
|
|||||||
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
|
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
|
||||||
# For a full list of active aliases, run `alias`.
|
# For a full list of active aliases, run `alias`.
|
||||||
|
|
||||||
|
# Load custom aliases
|
||||||
|
if [ -f "$ZSH_CUSTOM/aliases.zsh" ]; then
|
||||||
|
source "$ZSH_CUSTOM/aliases.zsh"
|
||||||
|
fi
|
||||||
|
|
||||||
# set directory to home
|
# set directory to home
|
||||||
cd ~
|
cd ~
|
||||||
|
|
||||||
@@ -79,8 +87,27 @@ if [ -x /usr/games/cowsay -a -x /usr/games/fortune -a -x /usr/games/lolcat ]; th
|
|||||||
fortune -s | cowsay | lolcat
|
fortune -s | cowsay | lolcat
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# NVM configuration
|
||||||
export NVM_DIR="$HOME/.nvm"
|
export NVM_DIR="$HOME/.nvm"
|
||||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
||||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
||||||
|
|
||||||
|
# Automatically use node version specified in .nvmrc if present
|
||||||
|
autoload -U add-zsh-hook
|
||||||
|
load-nvmrc() {
|
||||||
|
local nvmrc_path="$(nvm_find_nvmrc)"
|
||||||
|
if [ -n "$nvmrc_path" ]; then
|
||||||
|
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
|
||||||
|
if [ "$nvmrc_node_version" = "N/A" ]; then
|
||||||
|
nvm install
|
||||||
|
elif [ "$nvmrc_node_version" != "$(nvm version)" ]; then
|
||||||
|
nvm use
|
||||||
|
fi
|
||||||
|
elif [ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ] && [ "$(nvm version)" != "$(nvm version default)" ]; then
|
||||||
|
nvm use default
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
add-zsh-hook chpwd load-nvmrc
|
||||||
|
load-nvmrc
|
||||||
|
|
||||||
[[ -s /home/acedanger/.autojump/etc/profile.d/autojump.sh ]] && source /home/acedanger/.autojump/etc/profile.d/autojump.sh autoload -U compinit && compinit -u
|
[[ -s /home/acedanger/.autojump/etc/profile.d/autojump.sh ]] && source /home/acedanger/.autojump/etc/profile.d/autojump.sh autoload -U compinit && compinit -u
|
||||||
|
|||||||
109
README.md
109
README.md
@@ -1,5 +1,96 @@
|
|||||||
## Aliases
|
|
||||||
Create a symlink from the `ZSH_CUSTOM` folder to the `dotfiles/my-aliases.zsh` file.
|
# dotfiles
|
||||||
|
|
||||||
|
My personal dotfiles and system setup configuration for Linux machines.
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
To set up a new machine, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/acedanger/dotfiles/main/bootstrap.sh | bash
|
||||||
|
```
|
||||||
|
|
||||||
|
## What's Included
|
||||||
|
|
||||||
|
### Package Managers
|
||||||
|
- [**Nala**](https://gitlab.com/volian/nala): A better front-end for `apt` with parallel downloads and improved interface
|
||||||
|
- [**VS Code**](https://code.visualstudio.com/): Microsoft's popular code editor
|
||||||
|
- [**GitHub CLI**](https://cli.github.com/): Official GitHub command-line tool
|
||||||
|
|
||||||
|
### Core Packages
|
||||||
|
- [`git`](https://git-scm.com/): Version control
|
||||||
|
- [`python3`](https://www.python.org/): Python runtime
|
||||||
|
- [`wget`](https://www.gnu.org/software/wget/) & [`curl`](https://curl.se/): Download utilities
|
||||||
|
- [`bat`](https://github.com/sharkdp/bat): A better `cat` with syntax highlighting
|
||||||
|
- [`cowsay`](https://github.com/piuccio/cowsay): For fun CLI messages
|
||||||
|
- [`lolcat`](https://github.com/busyloop/lolcat): Colorful terminal output
|
||||||
|
- [`fzf`](https://github.com/junegunn/fzf): Fuzzy finder
|
||||||
|
- [`zsh`](https://www.zsh.org/): Better shell
|
||||||
|
- [`nala`](https://gitlab.com/volian/nala): Better package manager for Debian/Ubuntu
|
||||||
|
|
||||||
|
### Shell Setup
|
||||||
|
- [**Oh My Zsh**](https://ohmyz.sh/): Framework for managing Zsh configuration
|
||||||
|
- [**Agnoster Theme**](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster): Beautiful terminal theme with Git integration
|
||||||
|
|
||||||
|
#### Zsh Plugins
|
||||||
|
1. [`zsh-autosuggestions`](https://github.com/zsh-users/zsh-autosuggestions): Suggests commands as you type based on history
|
||||||
|
2. [`zsh-syntax-highlighting`](https://github.com/zsh-users/zsh-syntax-highlighting): Syntax highlighting for the shell
|
||||||
|
3. [`zsh-you-should-use`](https://github.com/MichaelAquilina/zsh-you-should-use): Reminds you of existing aliases
|
||||||
|
4. [`git`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git): Git integration and aliases
|
||||||
|
5. [`docker`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/docker): Docker commands integration
|
||||||
|
6. [`docker-compose`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/docker-compose): Docker Compose integration
|
||||||
|
7. [`z`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/z): Quick directory jumping
|
||||||
|
8. [`ssh`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/ssh): SSH configuration and shortcuts
|
||||||
|
|
||||||
|
### Development Tools
|
||||||
|
- [**nvm**](https://github.com/nvm-sh/nvm): Node Version Manager for managing Node.js versions
|
||||||
|
- [**zoxide**](https://github.com/ajeetdsouza/zoxide): Smarter directory navigation (a modern replacement for `z`)
|
||||||
|
- [**VS Code**](https://code.visualstudio.com/): Code editor with essential extensions
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
### Automatic Setup
|
||||||
|
- Automatically installs and configures all necessary packages and tools
|
||||||
|
- Sets up Zsh as the default shell
|
||||||
|
- Configures Nala package manager with optimized mirrors
|
||||||
|
- Installs and configures Node.js LTS version via nvm
|
||||||
|
- Sets up VS Code with recommended extensions
|
||||||
|
|
||||||
|
### Dotfile Management
|
||||||
|
- Automatically symlinks all configuration files
|
||||||
|
- Manages Zsh configuration and plugins
|
||||||
|
- Sets up Git configuration
|
||||||
|
- Configures custom aliases and functions
|
||||||
|
|
||||||
|
### Custom Configurations
|
||||||
|
- Terminal greeting with fortune and cowsay
|
||||||
|
- Optimized Zsh history settings
|
||||||
|
- Improved command-line navigation with zoxide
|
||||||
|
- Automatic Node.js version switching using .nvmrc
|
||||||
|
|
||||||
|
## Installation Process
|
||||||
|
|
||||||
|
1. The script will first set up necessary package repositories:
|
||||||
|
- Nala package manager
|
||||||
|
- VS Code
|
||||||
|
- GitHub CLI
|
||||||
|
|
||||||
|
2. Install core packages using Nala for better performance
|
||||||
|
|
||||||
|
3. Set up the shell environment:
|
||||||
|
- Install Zsh and Oh My Zsh
|
||||||
|
- Configure Zsh plugins and themes
|
||||||
|
- Set up custom aliases and configurations
|
||||||
|
|
||||||
|
4. Install development tools:
|
||||||
|
- Set up nvm and Node.js
|
||||||
|
- Configure zoxide for better navigation
|
||||||
|
- Install and configure Git
|
||||||
|
|
||||||
|
## Manual Steps
|
||||||
|
|
||||||
|
If you need to manually set up aliases:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# Create new symlink
|
# Create new symlink
|
||||||
@@ -8,3 +99,17 @@ ln -s ~/dev/dotfiles/my-aliases.zsh ~/.oh-my-zsh/custom/aliases.zsh
|
|||||||
# If the symlink already exists, use -f to force creation
|
# If the symlink already exists, use -f to force creation
|
||||||
ln -sf ~/dev/dotfiles/my-aliases.zsh ~/.oh-my-zsh/custom/aliases.zsh
|
ln -sf ~/dev/dotfiles/my-aliases.zsh ~/.oh-my-zsh/custom/aliases.zsh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Post-Installation
|
||||||
|
|
||||||
|
After installation:
|
||||||
|
1. Start a new terminal session or run `zsh`
|
||||||
|
2. The shell will be configured with all plugins and settings
|
||||||
|
3. You can start using all installed tools and aliases
|
||||||
|
|
||||||
|
## Maintenance
|
||||||
|
|
||||||
|
To update your setup:
|
||||||
|
1. Pull the latest changes from the repository
|
||||||
|
2. Run the setup script again - it's designed to be idempotent
|
||||||
|
3. Start a new shell session to apply any changes
|
||||||
|
|||||||
40
bootstrap.sh
Executable file
40
bootstrap.sh
Executable file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
DOTFILES_REPO="acedanger/dotfiles"
|
||||||
|
DOTFILES_BRANCH="main"
|
||||||
|
DOTFILES_DIR="$HOME/dev/dotfiles"
|
||||||
|
|
||||||
|
# Colors for output
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[0;33m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
echo -e "${GREEN}Setting up your system...${NC}"
|
||||||
|
|
||||||
|
# Install git if not present
|
||||||
|
if ! command -v git &>/dev/null; then
|
||||||
|
echo -e "${YELLOW}Installing git...${NC}"
|
||||||
|
sudo apt update && sudo apt install -y git
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create dev directory if it doesn't exist
|
||||||
|
mkdir -p "$HOME/dev"
|
||||||
|
|
||||||
|
# Clone or update repository
|
||||||
|
if [ -d "$DOTFILES_DIR" ]; then
|
||||||
|
echo -e "${YELLOW}Updating existing dotfiles repository...${NC}"
|
||||||
|
cd "$DOTFILES_DIR"
|
||||||
|
git pull origin $DOTFILES_BRANCH
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}Cloning dotfiles repository...${NC}"
|
||||||
|
git clone "https://github.com/$DOTFILES_REPO.git" "$DOTFILES_DIR"
|
||||||
|
cd "$DOTFILES_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make scripts executable
|
||||||
|
chmod +x "$DOTFILES_DIR/setup/setup.sh"
|
||||||
|
|
||||||
|
# Run setup script
|
||||||
|
"$DOTFILES_DIR/setup/setup.sh"
|
||||||
|
|
||||||
|
echo -e "${GREEN}Bootstrap completed! Please restart your terminal for changes to take effect.${NC}"
|
||||||
10
setup/packages.list
Normal file
10
setup/packages.list
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
git
|
||||||
|
python3
|
||||||
|
wget
|
||||||
|
curl
|
||||||
|
bat
|
||||||
|
cowsay
|
||||||
|
lolcat
|
||||||
|
fzf
|
||||||
|
zsh
|
||||||
|
nala
|
||||||
143
setup/setup.sh
Executable file
143
setup/setup.sh
Executable file
@@ -0,0 +1,143 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
DOTFILES_DIR="$(dirname "$SCRIPT_DIR")"
|
||||||
|
|
||||||
|
# Colors for output
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[0;33m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
echo -e "${GREEN}Starting system setup...${NC}"
|
||||||
|
|
||||||
|
# Add apt repositories
|
||||||
|
echo -e "${YELLOW}Setting up apt repositories...${NC}"
|
||||||
|
|
||||||
|
# Install prerequisites
|
||||||
|
sudo apt-get install -y wget gpg apt-transport-https
|
||||||
|
|
||||||
|
# Setup Nala repository
|
||||||
|
echo -e "${YELLOW}Setting up Nala repository...${NC}"
|
||||||
|
echo "deb [arch=$(dpkg --print-architecture)] https://deb.volian.org/volian/ scar main" | sudo tee /etc/apt/sources.list.d/volian-archive-scar-unstable.list > /dev/null
|
||||||
|
wget -qO - https://deb.volian.org/volian/scar.key | sudo tee /etc/apt/trusted.gpg.d/volian-archive-scar-unstable.gpg > /dev/null
|
||||||
|
|
||||||
|
# Setup VS Code repository
|
||||||
|
echo -e "${YELLOW}Setting up VS Code repository...${NC}"
|
||||||
|
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /tmp/packages.microsoft.gpg
|
||||||
|
sudo install -D -o root -g root -m 644 /tmp/packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
|
||||||
|
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
|
||||||
|
rm /tmp/packages.microsoft.gpg
|
||||||
|
|
||||||
|
# Setup GitHub CLI repository
|
||||||
|
echo -e "${YELLOW}Setting up GitHub CLI repository...${NC}"
|
||||||
|
sudo mkdir -p -m 755 /etc/apt/keyrings
|
||||||
|
out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
|
||||||
|
&& sudo install -D -o root -g root -m 644 "$out" /etc/apt/keyrings/githubcli-archive-keyring.gpg \
|
||||||
|
&& rm "$out" \
|
||||||
|
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
|
||||||
|
|
||||||
|
# Update package lists
|
||||||
|
sudo apt update
|
||||||
|
|
||||||
|
# Install Nala first
|
||||||
|
echo -e "${YELLOW}Installing Nala package manager...${NC}"
|
||||||
|
sudo apt-get install -y nala
|
||||||
|
|
||||||
|
# Configure Nala mirrors
|
||||||
|
echo -e "${YELLOW}Configuring Nala mirrors...${NC}"
|
||||||
|
sudo nala fetch --auto --fetches 3
|
||||||
|
|
||||||
|
# Install remaining packages using Nala
|
||||||
|
echo -e "${YELLOW}Installing packages from packages.list...${NC}"
|
||||||
|
mapfile -t pkgs < <(grep -v '^//' "$SCRIPT_DIR/packages.list" | grep -v -e '^$' -e '^nala$')
|
||||||
|
sudo nala install -y "${pkgs[@]}"
|
||||||
|
|
||||||
|
# Install Zsh if not already installed
|
||||||
|
echo -e "${YELLOW}Installing Zsh...${NC}"
|
||||||
|
if ! command -v zsh &> /dev/null; then
|
||||||
|
sudo apt-get install -y zsh
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install Oh My Zsh
|
||||||
|
echo -e "${YELLOW}Installing Oh My Zsh...${NC}"
|
||||||
|
if [ ! -d "$HOME/.oh-my-zsh" ]; then
|
||||||
|
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
|
||||||
|
else
|
||||||
|
echo "Oh My Zsh already installed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install zoxide
|
||||||
|
echo -e "${YELLOW}Installing zoxide...${NC}"
|
||||||
|
if ! command -v zoxide &> /dev/null; then
|
||||||
|
curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash
|
||||||
|
|
||||||
|
# Ensure .local/bin is in PATH
|
||||||
|
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
|
||||||
|
echo 'export PATH="$PATH:$HOME/.local/bin"' >> "$HOME/.bashrc"
|
||||||
|
export PATH="$PATH:$HOME/.local/bin"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install nvm (Node Version Manager)
|
||||||
|
echo -e "${YELLOW}Installing nvm...${NC}"
|
||||||
|
if [ ! -d "$HOME/.nvm" ]; then
|
||||||
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Load nvm regardless of whether it was just installed or already existed
|
||||||
|
export NVM_DIR="$HOME/.nvm"
|
||||||
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||||
|
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
|
||||||
|
|
||||||
|
# Install and set up Node.js only if nvm is available
|
||||||
|
if command -v nvm &>/dev/null; then
|
||||||
|
# Install latest LTS version of Node.js
|
||||||
|
nvm install --lts
|
||||||
|
nvm use --lts
|
||||||
|
# Set the LTS version as default
|
||||||
|
nvm alias default 'lts/*'
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}Warning: nvm installation may require a new shell session${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install Zsh plugins
|
||||||
|
echo -e "${YELLOW}Installing Zsh plugins...${NC}"
|
||||||
|
ZSH_CUSTOM="$HOME/.oh-my-zsh/custom"
|
||||||
|
PLUGINS_DIR="$ZSH_CUSTOM/plugins"
|
||||||
|
|
||||||
|
# zsh-autosuggestions
|
||||||
|
if [ ! -d "$PLUGINS_DIR/zsh-autosuggestions" ]; then
|
||||||
|
git clone https://github.com/zsh-users/zsh-autosuggestions "$PLUGINS_DIR/zsh-autosuggestions"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# zsh-syntax-highlighting
|
||||||
|
if [ ! -d "$PLUGINS_DIR/zsh-syntax-highlighting" ]; then
|
||||||
|
git clone https://github.com/zsh-users/zsh-syntax-highlighting "$PLUGINS_DIR/zsh-syntax-highlighting"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# zsh-you-should-use
|
||||||
|
if [ ! -d "$PLUGINS_DIR/zsh-you-should-use" ]; then
|
||||||
|
git clone https://github.com/MichaelAquilina/zsh-you-should-use "$PLUGINS_DIR/zsh-you-should-use"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set up dotfiles
|
||||||
|
echo -e "${YELLOW}Setting up dotfiles...${NC}"
|
||||||
|
# Set up Oh My Zsh custom directory and aliases
|
||||||
|
ZSH_CUSTOM="$HOME/.oh-my-zsh/custom"
|
||||||
|
mkdir -p "$ZSH_CUSTOM"
|
||||||
|
ln -sf "$DOTFILES_DIR/my-aliases.zsh" "$ZSH_CUSTOM/aliases.zsh"
|
||||||
|
|
||||||
|
# Set up dotfiles in home directory
|
||||||
|
ln -sf "$DOTFILES_DIR/.zshrc" "$HOME/.zshrc"
|
||||||
|
ln -sf "$DOTFILES_DIR/.nanorc" "$HOME/.nanorc" 2>/dev/null || true
|
||||||
|
ln -sf "$DOTFILES_DIR/.profile" "$HOME/.profile" 2>/dev/null || true
|
||||||
|
ln -sf "$DOTFILES_DIR/.gitconfig" "$HOME/.gitconfig" 2>/dev/null || true
|
||||||
|
|
||||||
|
# Set Zsh as default shell if not already set
|
||||||
|
if [[ "$SHELL" != *"zsh"* ]]; then
|
||||||
|
echo -e "${YELLOW}Setting Zsh as default shell...${NC}"
|
||||||
|
chsh -s $(which zsh)
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${GREEN}Setup completed successfully!${NC}"
|
||||||
Reference in New Issue
Block a user