Skip to content

Latest commit

 

History

26 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

zsh

My ZSH Config

Supported platforms are Ubuntu and macOS.

Setup Ubuntu

# Install base dependencies
sudo apt update
sudo apt install -y git zsh bat gpg wget zoxide

# Install eza
sudo mkdir -p /etc/apt/keyrings
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
sudo apt install -y eza

# Ensure zsh is a valid login shell
grep -qxF '/usr/bin/zsh' /etc/shells || echo '/usr/bin/zsh' | sudo tee -a /etc/shells

mkdir -p "$HOME/.cache"
mkdir -p "$HOME/.config"
touch "$HOME/.cache/zshhistory"

# Clone and Install
git clone https://github.com/patrickdobler/zsh "$HOME/zsh-config"
cp -r "$HOME/zsh-config/.zshrc" "$HOME/.zshrc"
cp -r "$HOME/zsh-config/.config/zsh" "$HOME/.config/"

chsh -s /usr/bin/zsh

Setup macOS (Ghostty)

# Install Ghostty
brew install --cask ghostty
brew install git eza bat jq mas zoxide
brew tap buo/cask-upgrade

mkdir -p "$HOME/.cache"
mkdir -p "$HOME/.config"
touch "$HOME/.cache/zshhistory"

# Clone and Install
git clone https://github.com/patrickdobler/zsh "$HOME/zsh-config"
cp -r "$HOME/zsh-config/.zshrc" "$HOME/.zshrc"
cp -r "$HOME/zsh-config/.config/zsh" "$HOME/.config/"

chsh -s /bin/zsh

Screenshot

image

Dependencies

  • git - required to clone this repo and auto-download plugins on first startup
  • zsh-syntax-highlighting - auto-downloaded on first startup for syntax highlighting
  • zsh-autosuggestions - auto-downloaded on first startup for history-based suggestions
  • eza - modern replacement for the command-line program ls
  • bat - interactive cat replacement used without paging
  • zoxide - smarter directory navigation using the z command
  • jq - macOS-only dependency required by caskclean and caskmig to read Homebrew's cask metadata
  • mas - macOS-only dependency used by brew cu --include-mas for Mac App Store updates
  • homebrew-cask-upgrade - macOS-only dependency used by brewup (adds brew cu)
  • Ghostty - optional terminal emulator used in the macOS setup above

On the first shell startup, the config clones the pinned stable releases of zsh-autosuggestions and zsh-syntax-highlighting into ~/.config/zsh/plugins.

Ubuntu aliases and functions are only loaded on Linux systems with apt. Homebrew and Cask aliases and functions are only loaded on macOS.

Custom keybindings

Keys Action
shift+tab Accept autosuggest
home Move to the beginning of the line. If already at the beginning of the line, move to the beginning of the previous line, if any.
end Move to the end of the line. If already at the end of the line, move to the end of the next line, if any.
del Delete the character under the cursor.
ctrl+ Move forward one word, vi-style.
ctrl+ Move to the beginning of the previous word, vi-style.
ctrl+backspace Kill the word behind the cursor, without going past the point where insert mode was last entered.
ctrl+del Kill from the cursor to the end of the line.

Prompt

The prompt displays the current directory and Git branch information. The branch name is color-coded based on the repository state:

  • Green: Clean repository.
  • Yellow: Staged changes pending commit.
  • Red: Unstaged changes or untracked files.

Ubuntu Command Aliases

APT

  • aptc Remove unused packages and cached package files.
  • aptf Show information about a package.
  • apti Install one or more packages.
  • aptl List installed packages.
  • apto List packages with available updates.
  • aptp Remove packages including their configuration files.
  • aptr Remove one or more packages.
  • apts Search for packages.
  • aptu Update package indexes.
  • aptU Upgrade installed packages without refreshing package indexes first.
  • aptup Update package indexes and then upgrade installed packages.

Docker

Docker aliases and functions are loaded only when the docker command is installed on Ubuntu.

Command Description
dps List running containers alphabetically with name and uptime.
dpsa List all containers alphabetically with name, status, and uptime.
dports List running containers and their published ports.
dlog CONTAINER Show the last 200 log lines from a container.
dlogs CONTAINER Show the last 200 log lines and follow a container's logs.
dexec CONTAINER COMMAND Run an interactive command in a container.
dsh CONTAINER Open Bash in a container when available, otherwise open sh.
dstart CONTAINER Start a container.
dstop CONTAINER Stop a container.
drestart CONTAINER Restart a container.
drm CONTAINER Remove a stopped container.
dstats Show a current resource-usage snapshot.
dstatslive Show live container resource usage.
dtop CONTAINER Show processes running in a container.
dinspect OBJECT Show detailed Docker object metadata.
dip CONTAINER Show a container's internal IP addresses by network.
dc Run docker compose.
dcls List Compose projects.
dcps List containers in the current Compose project.
dcup Start the Compose project in the background.
dcbuild Build images and start the Compose project.
dcforce Recreate all containers in the Compose project.
dcupdate [SERVICE] Pull images and update the Compose project or selected services.
dcpull Pull Compose images without recreating containers.
dcdown Stop the Compose project and remove its containers and networks.
dcstop Stop Compose services without removing their containers.
dcstart Start existing Compose service containers.
dcrestart Restart Compose services.
dclog [SERVICE] Show the last 200 Compose log lines.
dclogs [SERVICE] Show the last 200 Compose log lines and follow them.
dcexec SERVICE COMMAND Run a command in a running Compose service.
dcrun SERVICE COMMAND Run a one-off Compose container and remove it afterwards.
dcconfig Render and validate the resolved Compose configuration.
dcimages List images used by the Compose project.
dctop Show processes running in Compose containers.
dcevents Follow events from the Compose project.
dimages List local images.
dpull IMAGE Pull an image.
drmi IMAGE Remove an image.
dbuild Build an image.
ddf Show Docker disk usage.
dinfo Show Docker system information.
dprune Interactively remove unused Docker data except volumes.
diprune Interactively remove unused images.
dcprune Interactively remove stopped containers.
dnprune Interactively remove unused networks.
dbprune Interactively remove unused build cache.
dvprune Interactively remove unused volumes.
dstatus Show the Docker systemd service status.
dservice-start Start the Docker systemd service.
dservice-stop Stop the Docker systemd service.
dservice-restart Restart the Docker systemd service.
dservice-enable Enable and immediately start the Docker systemd service.
djournal Follow logs from the Docker systemd service.

The cleanup aliases deliberately remain interactive and do not use --force, --volumes, or docker compose down -v.

Other

  • ssh-start Start Ubuntu's SSH service.
  • ssh-stop Stop Ubuntu's SSH service.
  • update-grub Regenerate Ubuntu's GRUB configuration.

Text Display

  • cat If bat is installed, the alias uses it as a cat replacement without paging.

macOS Command Aliases

Finder

  • showHidden Show hidden files in the Finder.
  • hideHidden Hide hidden files in the Finder.
  • oo Open the current directory in the Finder.

Software Updates

  • osupdate Get macOS software updates and update installed Homebrew and their installed packages.

Networking

  • ip Show the public IP address of the machine.
  • localip Show the local IP address of the machine.
  • dns Show the DNS servers used by the machine.

LaunchServices

  • lscleanup Clean up LaunchServices to remove duplicates in the "Open With" menu.

File Management

  • dsclean Recursively delete .DS_Store files.
  • dr Read the "defaults" values.

Homebrew

  • brewa auto uninstalls formulae that are no longer needed.
  • brewc cleans the cache.
  • brewC scrubs the cache, including downloads for the latest versions.
  • brewd checks your system for potential problems.
  • brewe edits given formula.
  • brewf shows information about given formula.
  • brewi installs given formula.
  • brewl lists installed formulae.
  • brewL lists installed formulae that don't depend on other installed formula.
  • brewo lists outdated installed formulae.
  • brewp removes all cache files older than 30d
  • brewr reinstalls given formula.
  • brews performs a search of formula names.
  • brewS manages background services with macOS' launchctl daemon manager.
  • brewt list installed packages with all dependencies
  • brewu updates Homebrew and all formulae.
  • brewU upgrades outdated formulae.
  • brewx uninstalls a given formula.
  • brewX deletes all installed versions of given formula.
  • brewup updates Homebrew and formulae, cleans and migrates casks, updates all casks including apps with built-in update mechanisms and Mac App Store apps, cleans the cache, and runs diagnostics.

Homebrew Cask

  • caskclean removes installed casks whose application is missing and permanently deletes selected Mac App Store applications left in the Trash before brew cu can reinstall them. Root-owned App Store bundles require administrator privileges.
  • caskmig migrates manually installed applications to Homebrew Cask, recognises Cask tokens with the common -app suffix, and loads matching Cask metadata in one batch for fast scans. The local function is adapted from cask-migrator.
  • caske edits given cask.
  • caskf shows information about given cask.
  • caski installs given cask.
  • caskl lists installed casks.
  • casko lists outdated installed casks.
  • caskr reinstalls given cask.
  • casks performs a search of cask tokens.
  • caskU upgrades given cask or all outdated casks, if none given.
  • caskx uninstalls given cask.
  • caskX uninstalls even if given cask does not appear to be present.
  • caskz zaps all files associated with given cask.

Advanced Command Aliases

ls

These aliases are shortcuts for the eza command, a modern replacement for ls.

  • l Show files and directories using eza's default view.
  • la Show almost all files and directories in long format with size, type, and human-readable format.
  • lr Show files and directories sorted by date in long format with size, type, and human-readable format.
  • lt Show files and directories sorted by date in long format with size, type, and human-readable format.
  • ll Show files and directories in long format with size, type, and human-readable format.
  • ldot List dot files.
  • lone Show files and directories in one line with indicators.
  • lrt Show files and directories in one line with indicators in reverse order.
  • lsr Recursive list of files and directories in long format with size, type, and human-readable format.
  • lamc Show files and directories in long format with size, type, and human-readable format, and access, modified, and created date.
  • llg Show files and directories in long format with size, type, and human-readable format in grid view.
  • tree Show the directory structure in a tree format up to a depth of 2.
  • treel Show files and directories in long format in a tree view up to a depth of 2.
  • treela Show almost all files and directories in long format with size, type, and human-readable format, including dot files, in a tree format up to a depth of 2.

If eza is not installed, these aliases are shortcuts for the ls command.

  • l Show files and directories with size, type, and human-readable format.
  • la Show almost all files and directories in long format with size, type, and human-readable format.
  • lr Show files and directories sorted by date in long format with size, type, and human-readable format.
  • lt Show files and directories sorted by date in long format with size, type, and human-readable format.
  • ll Show files and directories in long format with size, type, and human-readable format.
  • ldot List dot files.
  • lS Sort files and directories by size in a single column.
  • lart Sort files and directories by access time in a single column.
  • lrt Sort files and directories by modification time in a single column.
  • lsr Recursive list of files and directories in long format with size, type, and human-readable format.
  • lsn A column contains name of files and directories.
  • tree Show the directory structure in a tree format up to any depth.

Formatting

  • grep Enable colored output for grep.
  • sgrep Recursive search with line numbers and context for non-version control directories.

Command Line Shortcuts

  • t Show the last few lines of a file and follow it as it updates.
  • H Show the first few lines of output.
  • T Show the last few lines of output.
  • G Filter output with grep.
  • L Show output in less with pagination.
  • M Show output in most with pagination.
  • LL Show all output in less.
  • CA Show all output with non-printing characters.
  • NE Hide all error output.
  • NUL Hide all output.
  • P Colorize Python traceback output.

File Management

  • dud Show the size of directories in the current directory.
  • duf Show the size of files and directories in the current directory.
  • dus Show the size of directories sorted by size in the current directory.
  • fd Find directories with a specific name.
  • ff Find files with a specific name.
  • filecount Show the number of files in the current directory.

Other

  • h Show the command history.
  • hgrep Search command history.
  • help Show the manual for a command.
  • p Show information about running processes.
  • sortnr Sort in reverse numeric order.
  • unexport Remove an environment variable.
  • rm, cp, mv Prompt before overwriting or deleting files.
  • md Create a directory and any necessary parent directories.
  • .., ... Change the directory to the parent directory or grandparent directory.
  • cls Clear the terminal screen.
  • top If you have the htop process monitoring tool installed on your system, the alias will overwrite top with htop

Navigation

  • z Change to a frequently used directory by matching part of its path.

Functions

The extract function is a utility function that can extract files from a variety of compressed formats. To use the function, simply call it with the name of the compressed file(s) you want to extract, like so:

extract -v file1.tar.gz file2.zip

The gitpush function stages all changes, creates a commit with the message you pass in, and pushes the current branch.

The gitupdate function starts ssh-agent, adds ~/.ssh/github, and tests the connection to GitHub.

Credits

About

My ZSH Config without powerlevel10k

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages