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
- aliases - List all available shortcuts
- brew - Homebrew aliases
- colored-man-pages - Colorize man pages
- rsync - rsync aliases
- nmap - nmap aliases
- sudo - Press ESC twice to prefix command with sudo
- systemadmin - Sysadmin aliases and functions
Custom Functions
Custom shell functions are defined in .config/dotfiles/functions.sh
and provide powerful utilities.
Available Functions
Function | Description | Usage |
---|---|---|
lsfn | List all functions with descriptions | lsfn |
b64d | Decode base64 string | b64d "encoded_string" |
b64e | Encode string to base64 | b64e "plain_text" |
browser | Start Browsh terminal web browser | browser [url] |
cheat_glow | View cheat sheets with Glow | cheat_glow <cheatsheet> |
check_cert | Check SSL certificate for domain | check_cert example.com |
dks | Decode Kubernetes secret | dks <secret_name> [namespace] |
kbp | Kill process on port | kbp 8080 |
randompass | Generate random password | randompass [length] |
tools | Execute remote utility scripts | tools [script_name] [args] |
timestampd | Convert timestamp to date | timestampd 1234567890 |
timestampe | Convert date to timestamp | timestampe "2023-01-01" |
urld | URL decode string | urld "encoded%20url" |
urle | URL encode string | urle "plain url" |
vault-cp | Copy Vault secret | vault-cp <source_path> <dest_path> |
weather | Check weather for location | weather [city] |
Function Examples
Base64 Encoding/Decoding
# Encode
$ b64e "Hello World"
SGVsbG8gV29ybGQ=
# Decode
$ b64d "SGVsbG8gV29ybGQ="
Hello World
URL Encoding/Decoding
# Encode
$ urle "hello world"
hello%20world
# Decode
$ urld "hello%20world"
hello world
Kubernetes Secret Decoding
# Decode secret in default namespace
$ dks my-secret
# Decode secret in specific namespace
$ dks my-secret production
Certificate Checking
$ check_cert example.com
# Shows certificate expiration, issuer, and other details
Port Management
# Kill process running on port 8080
$ kbp 8080
Password Generation
# Generate 16-character password (default)
$ randompass
# Generate 32-character password
$ randompass 32
Timestamp Conversion
# 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:
# 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:
# 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:
- zsh-completions - Community completions
- 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:
$ cheat -l -p personal
View a cheatsheet:
$ cheat <cheatsheet_name>
Enhanced viewing with Glow:
$ cheat_glow <cheatsheet_name>
# Renders cheatsheet with nice markdown formatting
Creating Custom Cheatsheets
Create your own cheatsheets in ~/.config/cheat/cheatsheets/personal/
:
# 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:
# 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
:
plugins=(
git
docker
# ... existing plugins ...
your-new-plugin
)
Custom Functions
Add your own functions to .config/dotfiles/functions.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:
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:
Consider adding tmux for:
- Multiple terminal sessions
- Session persistence
- Split panes and windows
Troubleshooting
Slow Shell Startup
If shell startup is slow:
# 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:
$ rm ~/.zcompdump*
$ exec zsh
Function Not Found
Ensure functions are sourced:
$ source ~/.config/dotfiles/functions.sh
# Or restart shell
$ exec zsh
Theme Issues
If theme doesn't display correctly:
# 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