Skip to content

Shell Customization

This document covers the shell customization provided by this dotfiles repository, including oh-my-zsh configuration, plugins, custom functions, and completions.

Zsh & oh-my-zsh

Default Shell

This setup uses Zsh as the default shell, configured with the oh-my-zsh framework for enhanced functionality and ease of customization.

Custom Theme

A custom oh-my-zsh theme is included: this-is-tobi.zsh-theme

This theme combines:

  • gnzh theme - Clean, minimal design with git information
  • kube-ps1 plugin - Kubernetes context display in prompt

Features:

  • Git branch and status indicators
  • Current Kubernetes context and namespace
  • Colored command status (success/failure)
  • Username and hostname display
  • Compact directory path

oh-my-zsh Plugins

The following plugins are activated to enhance shell functionality:

Development Tools

  • git - Git aliases and functions
  • gitignore - gitignore.io from command line
  • gh - GitHub CLI completion
  • docker - Docker completion and aliases
  • docker-compose - Docker Compose completion and aliases

Language-Specific

  • golang - Go completion and aliases
  • node - Node.js documentation function
  • npm - npm completion and aliases
  • bun - Bun completion

DevOps & Cloud

  • ansible - Ansible aliases
  • helm - Helm completion and aliases
  • kubectl - kubectl completion and aliases
  • kubectx - Kubernetes context display
  • kind - Kind completion
  • minikube - Minikube completion
  • microk8s - MicroK8s completion and aliases
  • oc - OpenShift CLI completion
  • terraform - Terraform completion, aliases, and prompt function
  • scw - Scaleway CLI completion

System Utilities

Custom Functions

Custom shell functions are defined in .config/dotfiles/functions.sh and provide powerful utilities.

Available Functions

FunctionDescriptionUsage
lsfnList all functions with descriptionslsfn
b64dDecode base64 stringb64d "encoded_string"
b64eEncode string to base64b64e "plain_text"
browserStart Browsh terminal web browserbrowser [url]
cheat_glowView cheat sheets with Glowcheat_glow <cheatsheet>
check_certCheck SSL certificate for domaincheck_cert example.com
dksDecode Kubernetes secretdks <secret_name> [namespace]
kbpKill process on portkbp 8080
randompassGenerate random passwordrandompass [length]
toolsExecute remote utility scriptstools [script_name] [args]
timestampdConvert timestamp to datetimestampd 1234567890
timestampeConvert date to timestamptimestampe "2023-01-01"
urldURL decode stringurld "encoded%20url"
urleURL encode stringurle "plain url"
vault-cpCopy Vault secretvault-cp <source_path> <dest_path>
weatherCheck weather for locationweather [city]

Function Examples

Base64 Encoding/Decoding

sh
# Encode
$ b64e "Hello World"
SGVsbG8gV29ybGQ=

# Decode
$ b64d "SGVsbG8gV29ybGQ="
Hello World

URL Encoding/Decoding

sh
# Encode
$ urle "hello world"
hello%20world

# Decode
$ urld "hello%20world"
hello world

Kubernetes Secret Decoding

sh
# Decode secret in default namespace
$ dks my-secret

# Decode secret in specific namespace
$ dks my-secret production

Certificate Checking

sh
$ check_cert example.com
# Shows certificate expiration, issuer, and other details

Port Management

sh
# Kill process running on port 8080
$ kbp 8080

Password Generation

sh
# Generate 16-character password (default)
$ randompass

# Generate 32-character password
$ randompass 32

Timestamp Conversion

sh
# Timestamp to human-readable date
$ timestampd 1609459200
Fri Jan  1 00:00:00 UTC 2021

# Date to timestamp
$ timestampe "2021-01-01"
1609459200

The tools Function

The tools function is special - it allows executing remote utility scripts from the tools repository without installing them locally.

Usage:

sh
# List all available scripts
$ tools

# View script help
$ tools <script_name> -h

# Execute script
$ tools <script_name> [arguments]

Auto-completion: The tools function has tab-completion support. Type tools then press <Tab> to see available scripts.

Examples:

sh
# List scripts
$ tools

# Get help for a specific script
$ tools clone-subdir -h

# Execute script
$ tools clone-subdir -u https://github.com/user/repo -s subdir -o output

CLI Completions

CLI completions are managed via:

  1. zsh-completions - Community completions
  2. completions.sh - Custom completion definitions

Installed Completions

Completions are automatically installed for:

  • kubectl and kubectl plugins
  • docker and docker-compose
  • helm
  • terraform
  • ansible
  • npm, yarn, pnpm
  • gh (GitHub CLI)
  • All oh-my-zsh plugin tools

Custom Completions

Custom completions are defined in functions-completion.sh for:

  • tools function - Tab-complete script names
  • Custom functions with arguments
  • Project-specific commands

Cheatsheets

Installation

The cheat tool is installed with additional custom cheatsheets.

Personal Cheatsheets

Extra cheatsheets from this-is-tobi/cheatsheets are available.

List personal cheatsheets:

sh
$ cheat -l -p personal

View a cheatsheet:

sh
$ cheat <cheatsheet_name>

Enhanced viewing with Glow:

sh
$ cheat_glow <cheatsheet_name>
# Renders cheatsheet with nice markdown formatting

Creating Custom Cheatsheets

Create your own cheatsheets in ~/.config/cheat/cheatsheets/personal/:

sh
# Create new cheatsheet
$ vim ~/.config/cheat/cheatsheets/personal/mycmd

# Content example:
# To do something useful:
mycmd --flag value

# To do something else:
mycmd --other-flag

Customization Tips

Adding Custom Aliases

Edit .zshrc to add personal aliases:

sh
# Add to ~/.zshrc
alias myalias="command --with-flags"
alias ll="eza -la"
alias k="kubectl"

Adding More Plugins

Add oh-my-zsh plugins in .zshrc:

sh
plugins=(
  git
  docker
  # ... existing plugins ...
  your-new-plugin
)

Custom Functions

Add your own functions to .config/dotfiles/functions.sh:

sh
# Add custom function
myfunction() {
  echo "This is my custom function"
  # Your code here
}

Environment Variables

Use .config/dotfiles/env.sh for custom environment variables:

sh
export MY_VAR="value"
export PATH="$HOME/my-bin:$PATH"
export CONTEXT7_API_KEY="your_key"

Terminal Multiplexer Integration

While not included by default, these dotfiles work great with:

  • tmux - Terminal multiplexer
  • screen - Terminal multiplexer

Consider adding tmux for:

  • Multiple terminal sessions
  • Session persistence
  • Split panes and windows

Troubleshooting

Slow Shell Startup

If shell startup is slow:

sh
# Profile startup time
$ time zsh -i -c exit

# Disable plugins one by one to find the culprit
# Edit ~/.zshrc and comment out plugins

Completion Not Working

Rebuild completion cache:

sh
$ rm ~/.zcompdump*
$ exec zsh

Function Not Found

Ensure functions are sourced:

sh
$ source ~/.config/dotfiles/functions.sh
# Or restart shell
$ exec zsh

Theme Issues

If theme doesn't display correctly:

sh
# Ensure oh-my-zsh is installed
$ ls ~/.oh-my-zsh

# Verify theme file exists
$ ls ~/.oh-my-zsh/custom/themes/this-is-tobi.zsh-theme

# Check .zshrc theme setting
$ grep "ZSH_THEME" ~/.zshrc