BCS Blog

COBOL, z/OS performance measurement, and systems programming updates.

Open Portal

Enhance Terminal

By Arch Brooks on January 19, 2026 in Programming

This script will install upgrades.

#!/bin/bash

# Ultimate Linux Terminal Setup Script
# Run with: bash setup_terminal.sh

set -e

echo "🚀 Starting Ultimate Terminal Setup..."

# Detect package manager
if command -v apt &> /dev/null; then
    PKG_MANAGER="apt"
    INSTALL_CMD="sudo apt install -y"
    UPDATE_CMD="sudo apt update"
elif command -v dnf &> /dev/null; then
    PKG_MANAGER="dnf"
    INSTALL_CMD="sudo dnf install -y"
    UPDATE_CMD="sudo dnf check-update"
elif command -v pacman &> /dev/null; then
    PKG_MANAGER="pacman"
    INSTALL_CMD="sudo pacman -S --noconfirm"
    UPDATE_CMD="sudo pacman -Sy"
else
    echo "❌ Unsupported package manager"
    exit 1
fi

echo "📦 Detected package manager: $PKG_MANAGER"
$UPDATE_CMD

# Install essential dependencies
echo "📥 Installing essential packages..."
$INSTALL_CMD git curl wget zsh tmux neovim

# Install modern CLI tools
echo "🔧 Installing modern CLI tools..."

# fzf - fuzzy finder
if [ ! -d ~/.fzf ]; then
    git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
    ~/.fzf/install --all
fi

# bat - better cat
if ! command -v bat &> /dev/null && ! command -v batcat &> /dev/null; then
    case $PKG_MANAGER in
        apt) $INSTALL_CMD bat ;;
        dnf) $INSTALL_CMD bat ;;
        pacman) $INSTALL_CMD bat ;;
    esac
fi

# exa/eza - better ls
if ! command -v eza &> /dev/null; then
    case $PKG_MANAGER in
        apt) 
            $INSTALL_CMD gpg
            wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sudo gpg --dearmor -o /etc/apt/keyrings/gierens.gpg
            echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | sudo tee /etc/apt/sources.list.d/gierens.list
            sudo chmod 644 /etc/apt/keyrings/gierens.gpg /etc/apt/sources.list.d/gierens.list
            sudo apt update
            $INSTALL_CMD eza
            ;;
        dnf) $INSTALL_CMD eza ;;
        pacman) $INSTALL_CMD eza ;;
    esac
fi

# ripgrep - better grep
if ! command -v rg &> /dev/null; then
    $INSTALL_CMD ripgrep
fi

# fd - better find
if ! command -v fd &> /dev/null; then
    case $PKG_MANAGER in
        apt) $INSTALL_CMD fd-find ;;
        *) $INSTALL_CMD fd ;;
    esac
fi

# zoxide - smarter cd
if ! command -v zoxide &> /dev/null; then
    curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash
fi

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

# Install Oh My Zsh
if [ ! -d ~/.oh-my-zsh ]; then
    echo "🎨 Installing Oh My Zsh..."
    sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
fi

# Install Zsh plugins
echo "🔌 Installing Zsh plugins..."
ZSH_CUSTOM=${ZSH_CUSTOM:-~/.oh-my-zsh/custom}

# zsh-autosuggestions
if [ ! -d "$ZSH_CUSTOM/plugins/zsh-autosuggestions" ]; then
    git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
fi

# zsh-syntax-highlighting
if [ ! -d "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" ]; then
    git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
fi

# zsh-completions
if [ ! -d "$ZSH_CUSTOM/plugins/zsh-completions" ]; then
    git clone https://github.com/zsh-users/zsh-completions $ZSH_CUSTOM/plugins/zsh-completions
fi

# Configure .zshrc
echo "⚙️  Configuring Zsh..."
cat > ~/.zshrc << 'EOF'
# Path to oh-my-zsh installation
export ZSH="$HOME/.oh-my-zsh"

# Plugins
plugins=(
    git
    zsh-autosuggestions
    zsh-syntax-highlighting
    zsh-completions
    docker
    kubectl
    fzf
    sudo
    history
)

source $ZSH/oh-my-zsh.sh

# Starship prompt
eval "$(starship init zsh)"

# Zoxide (smarter cd)
eval "$(zoxide init zsh)"

# Aliases - Modern CLI tools
alias ls='eza --icons --group-directories-first'
alias ll='eza -la --icons --group-directories-first'
alias la='eza -a --icons --group-directories-first'
alias lt='eza --tree --level=2 --icons'
alias cat='batcat 2>/dev/null || bat'
alias grep='rg'
alias find='fd'
alias cd='z'

# Useful aliases
alias zshconfig='nvim ~/.zshrc'
alias update='$UPDATE_CMD && $INSTALL_CMD'
alias cls='clear'
alias ..='cd ..'
alias ...='cd ../..'

# Git aliases
alias gs='git status'
alias ga='git add'
alias gc='git commit'
alias gp='git push'
alias gl='git log --oneline --graph --decorate'

# FZF configuration
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border'

# History configuration
HISTSIZE=10000
SAVEHIST=10000
setopt SHARE_HISTORY

# Enable autocompletions
autoload -Uz compinit && compinit
EOF

# Configure Starship
echo "🌟 Configuring Starship..."
mkdir -p ~/.config
cat > ~/.config/starship.toml << 'EOF'
format = """
[┌───────────────────>](bold green)
[│](bold green)$directory$git_branch$git_status$python$nodejs$rust$golang$docker_context
[└─>](bold green) """

[directory]
style = "blue bold"
truncation_length = 3
truncate_to_repo = true

[git_branch]
symbol = "🌱 "
style = "bold purple"

[git_status]
style = "bold yellow"

[character]
success_symbol = "[➜](bold green)"
error_symbol = "[✗](bold red)"

[python]
symbol = "🐍 "

[nodejs]
symbol = "⬢ "

[rust]
symbol = "🦀 "

[golang]
symbol = "🐹 "

[docker_context]
symbol = "🐳 "
EOF

# Configure tmux
echo "📺 Configuring tmux..."
cat > ~/.tmux.conf << 'EOF'
# Enable mouse mode
set -g mouse on

# Set prefix to Ctrl+a
unbind C-b
set -g prefix C-a
bind C-a send-prefix

# Split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %

# Reload config
bind r source-file ~/.tmux.conf \; display "Config reloaded!"

# Start windows and panes at 1
set -g base-index 1
setw -g pane-base-index 1

# Better colors
set -g default-terminal "screen-256color"

# Status bar
set -g status-style bg=black,fg=white
set -g status-left "#[fg=green]Session: #S "
set -g status-right "#[fg=cyan]%d %b %R"
EOF

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

echo ""
echo "✅ Installation complete!"
echo ""
echo "📝 What's installed:"
echo "  - Zsh with Oh My Zsh"
echo "  - Starship prompt (beautiful, fast prompt)"
echo "  - fzf (fuzzy finder - Ctrl+R for history, Ctrl+T for files)"
echo "  - bat (syntax-highlighted cat)"
echo "  - eza (modern ls with icons)"
echo "  - ripgrep (faster grep)"
echo "  - fd (faster find)"
echo "  - zoxide (smarter cd - type 'z <partial-name>')"
echo "  - tmux (terminal multiplexer)"
echo "  - Plugins: autosuggestions, syntax highlighting, completions"
echo ""
echo "🎯 Key shortcuts:"
echo "  - Ctrl+R: Search command history with fzf"
echo "  - Ctrl+T: Search files with fzf"
echo "  - Alt+C: Change directory with fzf"
echo "  - Type 'z <dir>': Jump to frequently used directories"
echo "  - Tmux prefix: Ctrl+a (then | for vertical, - for horizontal split)"
echo ""
echo "🔄 Please restart your terminal or run: source ~/.zshrc"
echo ""
echo "💡 Pro tip: Type 'ls', 'll', or 'lt' to see your new icons!"
EOF

This script will uninstall terminal enhancemens.

#!/bin/bash

# Terminal Setup Uninstall Script
# Run with: bash uninstall_terminal.sh

set -e

echo "🗑️  Starting Terminal Setup Uninstall..."
echo ""
echo "This will remove:"
echo "  - Oh My Zsh"
echo "  - Starship prompt"
echo "  - fzf"
echo "  - Zoxide"
echo "  - Configuration files (.zshrc, .tmux.conf, starship.toml)"
echo ""
read -p "Are you sure you want to continue? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
    echo "Cancelled."
    exit 1
fi

# Backup existing configs before removal
BACKUP_DIR=~/terminal_setup_backup_$(date +%Y%m%d_%H%M%S)
echo "📦 Creating backup at $BACKUP_DIR..."
mkdir -p $BACKUP_DIR

# Backup files if they exist
[ -f ~/.zshrc ] && cp ~/.zshrc $BACKUP_DIR/
[ -f ~/.tmux.conf ] && cp ~/.tmux.conf $BACKUP_DIR/
[ -f ~/.config/starship.toml ] && cp ~/.config/starship.toml $BACKUP_DIR/

echo "✅ Backup created"

# Detect package manager
if command -v apt &> /dev/null; then
    PKG_MANAGER="apt"
    REMOVE_CMD="sudo apt remove -y"
elif command -v dnf &> /dev/null; then
    PKG_MANAGER="dnf"
    REMOVE_CMD="sudo dnf remove -y"
elif command -v pacman &> /dev/null; then
    PKG_MANAGER="pacman"
    REMOVE_CMD="sudo pacman -R --noconfirm"
else
    echo "⚠️  Could not detect package manager - will skip package removal"
    PKG_MANAGER="none"
fi

# Uninstall Oh My Zsh
if [ -d ~/.oh-my-zsh ]; then
    echo "🗑️  Removing Oh My Zsh..."
    rm -rf ~/.oh-my-zsh
    rm -rf ~/.oh-my-zsh.* 2>/dev/null || true
fi

# Remove Zsh plugins directory
if [ -d ~/.oh-my-zsh ]; then
    rm -rf ~/.oh-my-zsh
fi

# Uninstall Starship
if command -v starship &> /dev/null; then
    echo "🗑️  Removing Starship..."
    sudo rm -f $(which starship)
    rm -f ~/.config/starship.toml
fi

# Uninstall fzf
if [ -d ~/.fzf ]; then
    echo "🗑️  Removing fzf..."
    ~/.fzf/uninstall
    rm -rf ~/.fzf
fi

# Uninstall zoxide
if command -v zoxide &> /dev/null; then
    echo "🗑️  Removing zoxide..."
    sudo rm -f $(which zoxide)
    rm -rf ~/.local/share/zoxide 2>/dev/null || true
fi

# Remove configuration files
echo "🗑️  Removing configuration files..."
rm -f ~/.zshrc
rm -f ~/.zshrc.pre-oh-my-zsh*
rm -f ~/.tmux.conf
rm -f ~/.config/starship.toml

# Optional: Remove installed packages
echo ""
read -p "Do you want to remove installed packages (bat, eza, ripgrep, fd, tmux, zsh)? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
    if [ "$PKG_MANAGER" != "none" ]; then
        echo "🗑️  Removing packages..."
        
        case $PKG_MANAGER in
            apt)
                sudo apt remove -y bat eza ripgrep fd-find tmux 2>/dev/null || true
                ;;
            dnf)
                sudo dnf remove -y bat eza ripgrep fd tmux 2>/dev/null || true
                ;;
            pacman)
                sudo pacman -R --noconfirm bat eza ripgrep fd tmux 2>/dev/null || true
                ;;
        esac
    fi
fi

# Restore default shell to bash
if [ "$SHELL" = "$(which zsh)" ]; then
    echo "🐚 Restoring default shell to bash..."
    read -p "Change default shell back to bash? (y/N): " -n 1 -r
    echo
    if [[ $REPLY =~ ^[Yy]$ ]]; then
        chsh -s $(which bash)
        echo "✅ Shell changed to bash (restart terminal for changes)"
    fi
fi

# Restore original .bashrc if backed up by Oh My Zsh
if [ -f ~/.bashrc.pre-oh-my-zsh ]; then
    echo "📝 Found backed up .bashrc..."
    read -p "Restore original .bashrc? (y/N): " -n 1 -r
    echo
    if [[ $REPLY =~ ^[Yy]$ ]]; then
        mv ~/.bashrc.pre-oh-my-zsh ~/.bashrc
        echo "✅ Original .bashrc restored"
    fi
fi

echo ""
echo "✅ Uninstall complete!"
echo ""
echo "📦 Your original configs are backed up at: $BACKUP_DIR"
echo ""
echo "🔄 Please restart your terminal or run: exec bash"
echo ""
echo "Note: If you want to keep zsh, neovim, or git installed,"
echo "      you can remove them manually with your package manager."
echo ""

After successful xecution of this script the un installation will be complete.


Views: 11 | Permalink: https://bcs.archman.us/blog.php?slug=enhance-terminal


Comments

No comments yet.