apt-get-tui.sh: A Sleek, Menu-Driven Package Manager Interface for Ubuntu & Debian

apt-get-tui.sh Banner

If you manage Debian or Ubuntu servers or workstations, you probably spend a lot of time typing commands like apt-get install, apt-cache search, or checking dependencies manually. While apt commands are incredibly powerful, remembering the less-frequent options—like pinning packages with hold, tracing reverse dependencies, downloading source archives, or configuring custom proxy configurations—can interrupt your workflow.

To bring speed, comfort, and structure to command-line package management, I built apt-get-tui.sh.

It is a lightweight, pure-Bash Text User Interface (TUI) that organizes every common apt-get, apt-cache, and apt-mark operation into a clean, side-by-side vertical grid. Best of all, package entry fields support full TAB autocomplete, so you don’t have to guess or copy-paste package names.


Technical Highlights: How It Works under the Hood

Despite being a lightweight script, apt-get-tui.sh employs several interesting scripting techniques:

1) Truecolor Color Themes (Catppuccin Latte & Ayu Dark)

The script features terminal themes: Catppuccin Latte (light mode, the default) and Ayu Dark (dark mode). The themes are applied using 24-bit truecolor escape sequences.
The themes can be customized:
– Setting the environment variable APT_TUI_THEME=dark or APT_TUI_THEME=light
– Running the script with flags like ./apt-get-tui.sh --dark or ./apt-get-tui.sh --light
– Toggling the theme live while running the script via option 80 in the menu.

2) Zero-Drift Column Formatting

A common problem when printing terminal menus with colors is that ANSI color codes add “invisible” characters to strings, which breaks standard spacing and text padding.
To keep columns perfectly aligned, apt-get-tui.sh calculates the width of printed strings based on their visible length using ${#var} on clean text before wrapping them in color sequences. This ensures a neat, multi-column grid layout regardless of which theme is loaded.

3) Cleanup Trap Handling

When generating autocomplete options, the script writes temporary cache files to /tmp. To prevent files from cluttering up your system, a Bash EXIT trap is declared:

cleanup() { rm -rf "$WORKDIR"; }
trap cleanup EXIT

No matter how the script exits (gracefully or via a system interrupt), the temporary wordlists are always cleaned up immediately.


Setup & Usage

To get started, you can clone the public scripts-public repository:

# Clone the repository
git clone https://github.com/Richie086/scripts-public.git
cd scripts-public

# Make the script executable
chmod +x bash/apt-get-tui.sh

# Run with Catppuccin Latte (light theme)
./bash/apt-get-tui.sh

# Or run with Ayu Dark (dark theme)
./bash/apt-get-tui.sh --dark

Alternatively, you can download the apt-get-tui.sh script directly via its GitHub permalink:

# Download the script directly
curl -LO https://raw.githubusercontent.com/Richie086/scripts-public/main/bash/apt-get-tui.sh

# Make it executable
chmod +x apt-get-tui.sh

# Run the TUI
./apt-get-tui.sh

Standout Features

1) Real-Time TAB Autocomplete

Rather than typing package names manually, the script uses rlwrap to wrap standard console input prompts.

When you choose an option like Install or Purge, apt-get-tui.sh generates a local wordlist in /tmp using queries like apt-cache pkgnames, dpkg-query, or apt-mark showhold. When you type the first few letters of a package and press <TAB>, it automatically completes the name. Pressing double-<TAB> prints all matching package options.
If rlwrap is not installed on your system, the script will notice on the first run and offer to install it for you automatically.

2) Quick Package Info & Versions

Need to know what a package does or which version is available? The script links directly into apt show and apt-cache policy. You can instantly inspect the installed version, the candidate version in the upstream repositories, the homepage, and the package size before committing to a download.

3) Visualizing Dependencies and Reverse Dependencies

Before uninstalling a package or installing custom developer tools, it is crucial to know what packages rely on them.
– Dependencies (apt-cache depends) lets you view exactly what libraries will be installed alongside your target.
– Reverse Dependencies (apt-cache rdepends) shows you what existing software on your system requires the target package, preventing accidental system breakage.


Option-by-Option Menu Guide

Here is a breakdown of the 26+ menu options available inside the TUI, structured by category columns:

Column 1: Find / Inspect

  1. Search Packages: Runs apt-cache search using a query word to find package names and short descriptions.
  2. Show Details: Runs apt show to display full package information (size, homepage, description, maintainers).
  3. Dependencies: Runs apt-cache depends to show direct dependencies, recommended packages, and suggested packages.
  4. Reverse Deps: Runs apt-cache rdepends to list other packages on the system that depend on the target package.
  5. Versions / Policy: Runs apt-cache policy to list installed/candidate versions, pin priorities, and repository origins.
  6. List Installed: Runs apt list --installed to print all packages currently installed on the system.
  7. List Upgradable: Runs apt list --upgradable to view all installed packages that have updates available in active repositories.

Column 2: Install / Remove

  1. Install: Runs sudo apt-get install to install new packages from the repositories.
  2. Reinstall: Runs sudo apt-get install --reinstall to repair packages by installing them again.
  3. Remove: Runs sudo apt-get remove to uninstall packages while leaving their configurations intact.
  4. Purge: Runs sudo apt-get purge to uninstall packages and delete all of their configurations.
  5. Download .deb: Runs apt-get download to download package .deb archives to your current directory without installing them.
  6. Download Source: Runs apt-get source to download the package source code archives.
  7. Build Deps: Runs sudo apt-get build-dep to install all dependencies required to compile the target package from source.

Column 3: Maintenance

  1. Update Lists: Runs sudo apt-get update to refresh the local package indices from remote repositories.
  2. Upgrade: Runs sudo apt-get upgrade to upgrade all outdated packages without deleting existing programs.
  3. Full Upgrade: Runs sudo apt-get full-upgrade to upgrade packages, handling changing dependencies by adding or deleting software if necessary.
  4. Autoremove: Runs sudo apt-get autoremove to delete unused packages that were installed automatically to satisfy dependencies.
  5. Clean Cache: Prompts you to clear all cached .deb archives (clean) or only clear outdated cache files (autoclean).
  6. Fix Broken: Runs sudo apt-get install --fix-broken to resolve corrupted dependencies and incomplete installs.
  7. Check Deps: Runs sudo apt-get check to verify the consistency of the package database and check for broken dependencies.

Column 4: Pinning / Sources

  1. Hold: Runs sudo apt-mark hold to lock a package version, preventing it from being automatically upgraded.
  2. Unhold: Runs sudo apt-mark unhold to unlock a package so that it can be upgraded again.
  3. Show Held: Runs apt-mark showhold to print a list of all packages currently frozen at their current version.
  4. Add Repo / PPA: Runs sudo add-apt-repository to register personal package archives or third-party repositories.
  5. Set Proxy: Automatically configures an apt proxy server (for HTTP and HTTPS) and saves it to /etc/apt/apt.conf.d/99proxy.

Column 5: Other

  • 80) Toggle Theme: Switches the TUI’s appearance between Ayu Dark and Catppuccin Latte.
  • 90) Raw apt-get Command: Runs raw arguments appended directly to sudo apt-get for advanced manual control.
  • 0) Exit: Safely cleans up the temporary cache files and exits back to your shell.

Final Thoughts

The apt-get-tui.sh script is not a replacement for high-level infrastructure tools like Ansible, but it is a perfect everyday companion for managing individual systems. Having a single organized dashboard makes Debian/Ubuntu package management fast, intuitive, and less prone to manual typos.


WordPress Summary

apt-get-tui.sh is an interactive, menu-driven Bash front-end for apt on Ubuntu and Debian. It groups search, install, purge, pinning, and maintenance tasks into an organized multi-column layout. With built-in <TAB> autocomplete powered by rlwrap, automatic proxy configuration, and live truecolor theme switching (Catppuccin Latte & Ayu Dark), it simplifies command-line package management.