Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions scripts/install-ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env bash
set -euo pipefail

# Ubuntu Setup Script for Starship + Sheldon + Rich Terminal Colors
# Run: bash scripts/install-ubuntu.sh

echo "==> Installing system dependencies..."
sudo apt update
sudo apt install -y zsh git curl wget unzip fontconfig xclip

echo "==> Installing bat (better cat)..."
sudo apt install -y bat
mkdir -p ~/.local/bin
[ ! -L ~/.local/bin/bat ] && ln -s /usr/bin/batcat ~/.local/bin/bat || true

echo "==> Installing eza (better ls)..."
if ! command -v eza &>/dev/null; then
wget -qO- https://github.com/eza-community/eza/releases/download/v0.18.9/eza_x86_64-unknown-linux-gnu.tar.gz | tar xz -C ~/.local/bin
fi

echo "==> Installing delta (better git diff)..."
if ! command -v delta &>/dev/null; then
DELTA_VERSION=$(curl -s https://api.github.com/repos/dandavison/delta/releases/latest | grep tag_name | cut -d '"' -f4)
wget -qO /tmp/delta.deb "https://github.com/dandavison/delta/releases/download/${DELTA_VERSION}/git-delta_${DELTA_VERSION}_amd64.deb"
sudo dpkg -i /tmp/delta.deb
rm /tmp/delta.deb
fi

echo "==> Installing starship prompt..."
if ! command -v starship &>/dev/null; then
curl -sS https://starship.rs/install.sh | sh -s -- -y
fi

echo "==> Installing sheldon plugin manager..."
if ! command -v sheldon &>/dev/null; then
curl --proto '=https' -fLsS https://rossmacarthur.github.io/install/crate.sh \
| bash -s -- --repo rossmacarthur/sheldon --to ~/.local/bin
fi

echo "==> Installing JetBrainsMono Nerd Font..."
FONT_DIR=~/.local/share/fonts/JetBrainsMono
if [ ! -d "$FONT_DIR" ]; then
mkdir -p ~/.local/share/fonts
wget -qO /tmp/JetBrainsMono.zip https://github.com/ryanoasis/nerd-fonts/releases/download/v3.1.1/JetBrainsMono.zip
unzip -qo /tmp/JetBrainsMono.zip -d "$FONT_DIR"
rm /tmp/JetBrainsMono.zip
fc-cache -fv
fi

echo "==> Creating config symlinks..."
CONFIG_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

mkdir -p ~/.config/sheldon

# Starship config
ln -sf "$CONFIG_DIR/.config/starship.toml" ~/.config/starship.toml

# Sheldon config
ln -sf "$CONFIG_DIR/.config/sheldon/plugins.toml" ~/.config/sheldon/plugins.toml

# Shell config files
ln -sf "$CONFIG_DIR/setup/zshrc" ~/.zshrc
ln -sf "$CONFIG_DIR/setup/exports" ~/.exports
ln -sf "$CONFIG_DIR/setup/aliases" ~/.aliases
ln -sf "$CONFIG_DIR/setup/functions" ~/.functions
ln -sf "$CONFIG_DIR/setup/colors" ~/.colors
ln -sf "$CONFIG_DIR/setup/extra" ~/.extra

# Git config
ln -sf "$CONFIG_DIR/setup/gitconfig" ~/.gitconfig
ln -sf "$CONFIG_DIR/setup/gitignore" ~/.gitignore

echo "==> Initializing sheldon (downloading plugins)..."
~/.local/bin/sheldon lock --update

echo "==> Setting zsh as default shell..."
if [ "$SHELL" != "$(which zsh)" ]; then
chsh -s "$(which zsh)"
fi

echo ""
echo "✓ Setup complete!"
echo ""
echo "IMPORTANT - SSH Terminal Setup:"
echo " 1. Your local terminal must use a Nerd Font (e.g., JetBrainsMono Nerd Font)"
echo " 2. Enable true color in your terminal settings"
echo " 3. Reconnect SSH session or run: exec zsh"
echo ""
echo "Test colors: printf '\\x1b[38;2;255;100;0mTRUECOLOR\\x1b[0m\\n'"
172 changes: 112 additions & 60 deletions setup/aliases
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# Enable aliases to be sudoed
# Enable aliases to be sudo'ed
alias sudo='sudo '
alias e="$EDITOR"

# Reload the .zshrc
alias reload='source $HOME/.zshrc && echo "Reloaded ~/.zshrc"'

# programs
alias preview="open -a '$PREVIEW'"
alias safari="open -a safari"
alias firefox="open -a firefox"
alias chrome="open -a google\ chrome"
alias cognito="open -a google\ chrome --args --incognito"
alias spotify="osascript ~/code/SpotifyControl/SpotifyControl.scpt"
alias imessage="open -a Messages"
# macOS-only application aliases
if [[ "$OSTYPE" == "darwin"* ]]; then
alias preview="open -a '$PREVIEW'"
alias safari="open -a safari"
alias firefox="open -a firefox"
alias chrome="open -a google\ chrome"
alias cognito="open -a google\ chrome --args --incognito"
alias spotify="osascript ~/code/SpotifyControl/SpotifyControl.scpt"
alias imessage="open -a Messages"
fi

# Easier navigation: .., ..., ...., ....., ~ and -
alias ..="cd .."
Expand All @@ -31,22 +33,43 @@ alias zx="cd ~/dev/experiments"
alias zr="cd ~/dev/rust"
alias zgj="cd ~/dev/go/src/github.com/johnie"
alias cl="clear"
alias pbc="pbcopy"
alias reboot="sudo shutdown -r now"
alias sov="osascript -e 'tell application \"System Events\" to sleep'"
alias pubkey="more ~/.ssh/id_ed25519.pub | pbcopy | echo '=> Public key copied to pasteboard.'"

# Clipboard - OS-specific
if [[ "$OSTYPE" == "darwin"* ]]; then
alias pbc="pbcopy"
alias pbcn="tr -d '\n' | pbcopy"
alias pubkey="more ~/.ssh/id_ed25519.pub | pbcopy | echo '=> Public key copied to pasteboard.'"
else
alias pbc="xclip -selection clipboard"
alias pbcn="tr -d '\n' | xclip -selection clipboard"
alias pubkey="cat ~/.ssh/id_ed25519.pub | xclip -selection clipboard && echo '=> Public key copied to clipboard.'"
fi

# macOS-only system controls
if [[ "$OSTYPE" == "darwin"* ]]; then
alias sov="osascript -e 'tell application \"System Events\" to sleep'"
fi

# Get week number
alias week='date +%V'

# be nice
alias doh='sudo $(history -p !-1)'

# handy things
alias wifi="airport"
alias wifion="networksetup -setairportpower en1 on"
alias wifioff="networksetup -setairportpower en1 off"
alias flushdns="sudo killall -HUP mDNSResponder"
# handy things - macOS WiFi
if [[ "$OSTYPE" == "darwin"* ]]; then
alias wifi="airport"
alias wifion="networksetup -setairportpower en1 on"
alias wifioff="networksetup -setairportpower en1 off"
fi

# Flush DNS - OS-specific
if [[ "$OSTYPE" == "darwin"* ]]; then
alias flushdns="sudo killall -HUP mDNSResponder"
else
alias flushdns="sudo systemd-resolve --flush-caches"
fi

if $(eza &>/dev/null)
then
Expand All @@ -60,9 +83,15 @@ alias gr='[ ! -z `git rev-parse --show-cdup` ] && cd `git rev-parse --show-cdup

# IP addresses
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="ipconfig getifaddr en1"
alias ips="ifconfig -a | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1'"

# Local IP - OS-specific
if [[ "$OSTYPE" == "darwin"* ]]; then
alias localip="ipconfig getifaddr en1"
else
alias localip="hostname -I | awk '{print \$1}'"
fi

# Enhanced WHOIS lookups
alias whois="whois -h whois-servers.net"

Expand Down Expand Up @@ -108,63 +137,86 @@ alias dc='docker compose'
alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'"
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""

# Trim new lines and copy to clipboard
alias pbcn="tr -d '\n' | pbcopy"

# Recursively delete `.DS_Store` files
alias cleanup="find . -name '*.DS_Store' -type f -ls -delete"

# Shortcuts
alias v="nvim"

# File size
alias fs="stat -f \"%z bytes\""
# File size - OS-specific
if [[ "$OSTYPE" == "darwin"* ]]; then
alias fs="stat -f \"%z bytes\""
else
alias fs="stat -c \"%s bytes\""
fi

# Hide/show all desktop icons (useful when presenting)
alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
# macOS-only Finder and desktop aliases
if [[ "$OSTYPE" == "darwin"* ]]; then
# Hide/show all desktop icons (useful when presenting)
alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"

# Show/Hide hidden files in Finder
alias showfiles="defaults write com.apple.finder AppleShowAllFiles YES && killall Finder"
alias hidefiles="defaults write com.apple.finder AppleShowAllFiles NO && killall Finder"
# Show/Hide hidden files in Finder
alias showfiles="defaults write com.apple.finder AppleShowAllFiles YES && killall Finder"
alias hidefiles="defaults write com.apple.finder AppleShowAllFiles NO && killall Finder"

# PlistBuddy alias, because sometimes `defaults` just doesn’t cut it
alias plistbuddy="/usr/libexec/PlistBuddy"
# PlistBuddy alias, because sometimes `defaults` just doesn't cut it
alias plistbuddy="/usr/libexec/PlistBuddy"
fi

# One of @janmoesens ProTip™s
# One of @janmoesen's ProTip™s
for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
alias "$method"="lwp-request -m '$method'"
done

# Stuff I never really use but cannot delete either because of http://xkcd.com/530/
alias stfu="osascript -e 'set volume output muted true'"
alias pumpitup="osascript -e 'set volume 10'"
# macOS-only volume and system controls
if [[ "$OSTYPE" == "darwin"* ]]; then
# Stuff I never really use but cannot delete either because of http://xkcd.com/530/
alias stfu="osascript -e 'set volume output muted true'"
alias pumpitup="osascript -e 'set volume 10'"
fi

# System log - OS-specific
if [[ "$OSTYPE" == "darwin"* ]]; then
alias msg='tail -f /var/log/system.log'
else
alias msg='journalctl -f'
fi

# macOS-only Homebrew aliases
if [[ "$OSTYPE" == "darwin"* ]]; then
# Shorter commands for `Homebrew`.
alias brewd="brew doctor"
alias brewi="brew install"
alias brewr="brew uninstall"
alias brews="brew search"
alias brewu="brew update --quiet \
&& brew upgrade \
&& brew cleanup"

# Empty the trash, the main HDD and on all mounted volumes,
# and clear Apple's system logs to improve shell startup speed.
alias empty-trash="sudo rm -frv /Volumes/*/.Trashes; \
sudo rm -frv ~/.Trash; \
sudo rm -frv /private/var/log/asl/*.asl; \
sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'"
fi

# MacOS log
alias msg='tail -f /var/log/system.log'
# Open command - OS-specific
if [[ "$OSTYPE" == "darwin"* ]]; then
alias o="open"
alias oo="open ."
else
alias o="xdg-open"
alias oo="xdg-open ."
fi

# Shorter commands for `Homebrew`.
alias brewd="brew doctor"
alias brewi="brew install"
alias brewr="brew uninstall"
alias brews="brew search"
alias brewu="brew update --quiet \
# Update command - OS-specific
if [[ "$OSTYPE" == "darwin"* ]]; then
alias update="sudo softwareupdate --install --all \
&& brew update \
&& brew upgrade \
&& brew cleanup"

# Empty the trash, the main HDD and on all mounted volumes,
# and clear Apple’s system logs to improve shell startup speed.
alias empty-trash="sudo rm -frv /Volumes/*/.Trashes; \
sudo rm -frv ~/.Trash; \
sudo rm -frv /private/var/log/asl/*.asl; \
sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'"

# Open from the terminal.
alias o="open"
alias oo="open ."

# Update applications and CLTs.
alias update="sudo softwareupdate --install --all \
&& brew update \
&& brew upgrade \
&& brew cleanup"
else
alias update="sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y"
fi
14 changes: 10 additions & 4 deletions setup/exports
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
export PATH=$HOME/bin:/usr/local/bin:/snap/bin:/opt/bin:$PATH
export PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
export PATH=$HOME/.local/bin:$HOME/bin:/usr/local/bin:/snap/bin:/opt/bin:$PATH
export PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin
export PATH=/usr/local/sbin:$PATH

export LANG=en_US.UTF-8

export GOPATH="$HOME/dev/go"
export PATH="$GOPATH/bin:$PATH"

# NVM - OS-specific paths
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm"
if [[ "$OSTYPE" == "darwin"* ]]; then
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm"
else
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
fi

export PATH=~/.npm-global/bin:$PATH
5 changes: 4 additions & 1 deletion setup/zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ for file in ~/.{extra,exports,aliases,functions,colors}; do
done
unset file

# macOS: Homebrew setup
if [[ "$OSTYPE" == "darwin"* ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi

eval "$(/opt/homebrew/bin/brew shellenv)"
eval "$(starship init zsh)"
eval "$(sheldon source)"