Developer Productivity Terminal Optimization: Enterprise Development Environment Configuration Guide
Developer productivity optimization through terminal and environment configuration represents a critical investment in engineering efficiency, where strategic automation and workflow enhancement can multiply output while reducing cognitive load and repetitive strain. This comprehensive guide explores enterprise-grade terminal optimization, advanced shell configurations, and productivity frameworks that transform development workflows.
Enterprise Developer Environment Architecture
Comprehensive Productivity Framework
Modern development environments require sophisticated configuration strategies that balance automation, discoverability, and consistency across distributed teams while maintaining security and compliance requirements.
Advanced Terminal Productivity Stack
┌─────────────────────────────────────────────────────────────────┐
│ Developer Productivity Environment Stack │
├─────────────────┬─────────────────┬─────────────────┬───────────┤
│ Shell │ Completion │ Navigation │ Tools │
│ Environment │ Framework │ & History │ & IDE │
├─────────────────┼─────────────────┼─────────────────┼───────────┤
│ ┌─────────────┐ │ ┌─────────────┐ │ ┌─────────────┐ │ ┌───────┐ │
│ │ Zsh/Bash │ │ │ Tab Complete│ │ │ fzf │ │ │ Neovim│ │
│ │ Oh-My-Zsh │ │ │ Auto-suggest│ │ │ ripgrep │ │ │ VSCode│ │
│ │ Starship │ │ │ Command Pred│ │ │ fd │ │ │ tmux │ │
│ │ Dotfiles │ │ │ Context Help│ │ │ bat │ │ │ Kitty │ │
│ └─────────────┘ │ └─────────────┘ │ └─────────────┘ │ └───────┘ │
│ │ │ │ │
│ • Customizable │ • Intelligent │ • Fuzzy Search │ • Integrated│
│ • Extensible │ • Context-aware │ • History Sync │ • Automated│
│ • Portable │ • Learn & Adapt │ • Multi-session │ • Scriptable│
└─────────────────┴─────────────────┴─────────────────┴───────────┘
Advanced Shell Configuration
Zsh with Oh-My-Zsh Enterprise Setup
#!/bin/bash
# install-dev-environment.sh
# Enterprise developer environment setup script
set -euo pipefail
# Color definitions
readonly RED='\033[0;31m'
readonly GREEN='\033[0;32m'
readonly YELLOW='\033[1;33m'
readonly BLUE='\033[0;34m'
readonly MAGENTA='\033[0;35m'
readonly CYAN='\033[0;36m'
readonly NC='\033[0m' # No Color
# Logging functions
log_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1" >&2
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1" >&2
}
# Detect OS
detect_os() {
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
OS="macOS"
VER=$(sw_vers -productVersion)
else
log_error "Unsupported OS: $OSTYPE"
exit 1
fi
log_info "Detected OS: $OS $VER"
}
# Install package manager dependencies
install_dependencies() {
log_info "Installing system dependencies..."
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux installation
sudo apt-get update
sudo apt-get install -y \
zsh \
git \
curl \
wget \
build-essential \
python3-pip \
nodejs \
npm \
fzf \
ripgrep \
fd-find \
bat \
tmux \
neovim \
jq \
htop \
ncdu \
tree \
autojump \
direnv
elif [[ "$OSTYPE" == "darwin"* ]]; then
# macOS installation with Homebrew
if ! command -v brew &> /dev/null; then
log_info "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
brew update
brew install \
zsh \
git \
curl \
wget \
fzf \
ripgrep \
fd \
bat \
tmux \
neovim \
jq \
htop \
ncdu \
tree \
autojump \
direnv \
starship \
exa \
procs \
dust \
duf \
broot \
bottom
fi
}
# Install Oh-My-Zsh
install_oh_my_zsh() {
log_info "Installing Oh-My-Zsh..."
if [ ! -d "$HOME/.oh-my-zsh" ]; then
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
else
log_warn "Oh-My-Zsh already installed, updating..."
cd "$HOME/.oh-my-zsh" && git pull
fi
# Install additional plugins
log_info "Installing Zsh plugins..."
# zsh-autosuggestions
if [ ! -d "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions" ]; then
git clone https://github.com/zsh-users/zsh-autosuggestions \
${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
fi
# zsh-syntax-highlighting
if [ ! -d "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting" ]; then
git clone https://github.com/zsh-users/zsh-syntax-highlighting \
${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
fi
# zsh-completions
if [ ! -d "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-completions" ]; then
git clone https://github.com/zsh-users/zsh-completions \
${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-completions
fi
# fzf-tab
if [ ! -d "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fzf-tab" ]; then
git clone https://github.com/Aloxaf/fzf-tab \
${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fzf-tab
fi
}
# Install Starship prompt
install_starship() {
log_info "Installing Starship prompt..."
if ! command -v starship &> /dev/null; then
curl -sS https://starship.rs/install.sh | sh -s -- --yes
else
log_warn "Starship already installed"
fi
# Create Starship configuration
mkdir -p "$HOME/.config"
create_starship_config
}
# Create optimized Zsh configuration
create_zsh_config() {
log_info "Creating optimized Zsh configuration..."
cat > "$HOME/.zshrc" << 'ZSHRC'
# Zsh Performance Profiling (uncomment to debug slow startup)
# zmodload zsh/zprof
# Path configuration
export PATH="$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH"
# Oh-My-Zsh configuration
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="robbyrussell" # Will be overridden by Starship
# Plugin configuration
plugins=(
git
docker
docker-compose
kubectl
terraform
aws
gcloud
npm
node
python
pip
golang
rust
tmux
fzf
autojump
direnv
zsh-autosuggestions
zsh-syntax-highlighting
zsh-completions
fzf-tab
)
# Performance optimizations
DISABLE_UNTRACKED_FILES_DIRTY="true"
COMPLETION_WAITING_DOTS="false"
DISABLE_AUTO_UPDATE="false"
# Load Oh-My-Zsh
source $ZSH/oh-my-zsh.sh
# Starship prompt
eval "$(starship init zsh)"
# FZF configuration
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
export FZF_DEFAULT_OPTS='
--height 40%
--layout=reverse
--border
--preview "bat --style=numbers --color=always --line-range :500 {}"
--preview-window=right:60%:wrap
'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND='fd --type d --hidden --follow --exclude .git'
# Aliases - Productivity Boosters
alias ll='ls -lah'
alias la='ls -A'
alias l='ls -CF'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias ~='cd ~'
# Enhanced commands with modern alternatives
if command -v exa &> /dev/null; then
alias ls='exa --icons'
alias ll='exa -la --icons --git'
alias tree='exa --tree --icons'
fi
if command -v bat &> /dev/null; then
alias cat='bat'
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
fi
if command -v procs &> /dev/null; then
alias ps='procs'
fi
if command -v dust &> /dev/null; then
alias du='dust'
fi
if command -v duf &> /dev/null; then
alias df='duf'
fi
if command -v bottom &> /dev/null; then
alias top='btm'
alias htop='btm'
fi
# Git aliases for productivity
alias gs='git status'
alias gst='git status --short --branch'
alias ga='git add'
alias gaa='git add --all'
alias gc='git commit --verbose'
alias gcm='git commit -m'
alias gco='git checkout'
alias gcb='git checkout -b'
alias gd='git diff'
alias gdc='git diff --cached'
alias gl='git log --oneline --graph --decorate'
alias gll='git log --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --abbrev-commit'
alias gp='git push'
alias gpu='git push -u origin HEAD'
alias gpl='git pull --rebase'
alias gf='git fetch --all --prune'
alias gr='git rebase'
alias gri='git rebase -i'
alias grc='git rebase --continue'
alias gra='git rebase --abort'
alias gclean='git clean -fd'
alias gbr='git branch --sort=-committerdate --format="%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:green)(%(committerdate:relative))%(color:reset) - %(contents:subject) - %(authorname)"'
# Docker aliases
alias d='docker'
alias dc='docker-compose'
alias dps='docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"'
alias dpsa='docker ps -a --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"'
alias di='docker images'
alias dex='docker exec -it'
alias dlog='docker logs -f'
alias dprune='docker system prune -af'
alias dstop='docker stop $(docker ps -q)'
alias drm='docker rm $(docker ps -aq)'
alias drmi='docker rmi $(docker images -q -f dangling=true)'
# Kubernetes aliases
alias k='kubectl'
alias kgp='kubectl get pods'
alias kgpa='kubectl get pods --all-namespaces'
alias kgs='kubectl get services'
alias kgd='kubectl get deployments'
alias kgi='kubectl get ingress'
alias kgn='kubectl get nodes'
alias kd='kubectl describe'
alias kdp='kubectl describe pod'
alias klog='kubectl logs -f'
alias kex='kubectl exec -it'
alias kctx='kubectl config current-context'
alias kns='kubectl config view --minify --output "jsonpath={..namespace}"'
alias ksetns='kubectl config set-context --current --namespace'
# Terraform aliases
alias tf='terraform'
alias tfi='terraform init'
alias tfp='terraform plan'
alias tfa='terraform apply'
alias tfd='terraform destroy'
alias tfv='terraform validate'
alias tff='terraform fmt -recursive'
# Python aliases
alias py='python3'
alias pip='pip3'
alias venv='python3 -m venv'
alias activate='source venv/bin/activate'
alias pytest='python -m pytest'
alias black='black --line-length 88'
alias isort='isort --profile black'
# Advanced functions
# Fuzzy find and cd
fcd() {
local dir
dir=$(find ${1:-.} -type d -not -path '*/.*' 2> /dev/null | fzf +m) && cd "$dir"
}
# Fuzzy find and open in editor
fe() {
local files
IFS=$'\n' files=($(fzf --query="$1" --multi --select-1 --exit-0))
[[ -n "$files" ]] && ${EDITOR:-vim} "${files[@]}"
}
# Git branch fuzzy checkout
gcof() {
local branches branch
branches=$(git branch --all | grep -v HEAD) &&
branch=$(echo "$branches" | fzf -d $(( 2 + $(wc -l <<< "$branches") )) +m) &&
git checkout $(echo "$branch" | sed "s/.* //" | sed "s#remotes/[^/]*/##")
}
# Kill process with fzf
fkill() {
local pid
pid=$(ps -ef | sed 1d | fzf -m | awk '{print $2}')
if [ "x$pid" != "x" ]; then
echo $pid | xargs kill -${1:-9}
fi
}
# Docker container interactive selector
dsh() {
local container
container=$(docker ps --format "table {{.Names}}\t{{.Status}}" | sed 1d | fzf | awk '{print $1}')
[ -n "$container" ] && docker exec -it "$container" /bin/bash
}
# Kubernetes pod interactive selector
ksh() {
local pod
pod=$(kubectl get pods --no-headers | fzf | awk '{print $1}')
[ -n "$pod" ] && kubectl exec -it "$pod" -- /bin/bash
}
# Quick backup function
backup() {
cp -r "$1" "$1.backup.$(date +%Y%m%d_%H%M%S)"
}
# Extract any archive
extract() {
if [ -f "$1" ]; then
case $1 in
*.tar.bz2) tar xjf "$1" ;;
*.tar.gz) tar xzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) unrar e "$1" ;;
*.gz) gunzip "$1" ;;
*.tar) tar xf "$1" ;;
*.tbz2) tar xjf "$1" ;;
*.tgz) tar xzf "$1" ;;
*.zip) unzip "$1" ;;
*.Z) uncompress "$1" ;;
*.7z) 7z x "$1" ;;
*) echo "'$1' cannot be extracted" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# Create and cd into directory
mkcd() {
mkdir -p "$1" && cd "$1"
}
# History configuration
HISTFILE="$HOME/.zsh_history"
HISTSIZE=100000
SAVEHIST=100000
setopt EXTENDED_HISTORY
setopt HIST_EXPIRE_DUPS_FIRST
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_SPACE
setopt HIST_VERIFY
setopt SHARE_HISTORY
# Key bindings
bindkey -e
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
bindkey '^R' history-incremental-search-backward
bindkey '^S' history-incremental-search-forward
bindkey '^P' up-line-or-history
bindkey '^N' down-line-or-history
bindkey '^A' beginning-of-line
bindkey '^E' end-of-line
bindkey '^K' kill-line
bindkey '^W' backward-kill-word
# Autocompletion settings
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
zstyle ':completion:*' menu select
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
zstyle ':completion:*:*:kill:*' menu yes select
zstyle ':completion:*:kill:*' force-list always
zstyle ':completion:*:*:docker:*' option-stacking yes
zstyle ':completion:*:*:docker-*:*' option-stacking yes
# Auto-suggest configuration
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#666666"
ZSH_AUTOSUGGEST_STRATEGY=(history completion)
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
# Load additional configurations
[ -f ~/.zshrc.local ] && source ~/.zshrc.local
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# Load direnv
eval "$(direnv hook zsh)"
# Performance profiling (uncomment to debug)
# zprof
ZSHRC
log_info "Zsh configuration created"
}
# Create Starship configuration
create_starship_config() {
log_info "Creating Starship configuration..."
cat > "$HOME/.config/starship.toml" << 'STARSHIP'
# Starship Configuration - Developer Optimized
format = """
[░▒▓](#a3aed2)\
[ ](bg:#a3aed2 fg:#090c0c)\
[](bg:#769ff0 fg:#a3aed2)\
$directory\
[](fg:#769ff0 bg:#394260)\
$git_branch\
$git_status\
[](fg:#394260 bg:#212736)\
$nodejs\
$rust\
$golang\
$php\
$python\
$docker_context\
$kubernetes\
[](fg:#212736 bg:#1d2230)\
$time\
[ ](fg:#1d2230)\
\n$character"""
[directory]
style = "fg:#e3e5e5 bg:#769ff0"
format = "[ $path ]($style)"
truncation_length = 3
truncation_symbol = "…/"
[directory.substitutions]
"Documents" = " "
"Downloads" = " "
"Music" = " "
"Pictures" = " "
[git_branch]
symbol = ""
style = "bg:#394260"
format = '[[ $symbol $branch ](fg:#769ff0 bg:#394260)]($style)'
[git_status]
style = "bg:#394260"
format = '[[($all_status$ahead_behind )](fg:#769ff0 bg:#394260)]($style)'
[nodejs]
symbol = ""
style = "bg:#212736"
format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)'
[rust]
symbol = ""
style = "bg:#212736"
format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)'
[golang]
symbol = ""
style = "bg:#212736"
format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)'
[php]
symbol = ""
style = "bg:#212736"
format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)'
[python]
symbol = ""
style = "bg:#212736"
format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)'
[docker_context]
symbol = ""
style = "bg:#06969A"
format = '[[ $symbol $context ](docker blue)]($style) $path'
[kubernetes]
symbol = "☸"
style = "bg:#326ce5"
format = '[[ $symbol $context/$namespace ](white bg:#326ce5)]($style)'
disabled = false
[kubernetes.context_aliases]
"dev.local.cluster.k8s" = "dev"
"gke_.*_(?P<var_cluster>[\\w-]+)" = "gke-$var_cluster"
[time]
disabled = false
time_format = "%R"
style = "bg:#1d2230"
format = '[[ $time ](fg:#a0a9cb bg:#1d2230)]($style)'
[character]
success_symbol = '[➜](bold green)'
error_symbol = '[✗](bold red)'
vicmd_symbol = '[V](bold green)'
[aws]
symbol = " "
format = '[[ $symbol ($version) ](bg:#FF9900)]($style)'
[cmd_duration]
min_time = 500
format = "took [$duration](bold yellow)"
[memory_usage]
disabled = false
threshold = 75
symbol = "🧠"
format = '$symbol [${ram_pct}](bold dimmed green)'
[package]
format = "via [🎁 $version](208 bold)"
STARSHIP
log_info "Starship configuration created"
}
# Create tmux configuration
create_tmux_config() {
log_info "Creating tmux configuration..."
cat > "$HOME/.tmux.conf" << 'TMUX'
# Tmux Configuration - Developer Optimized
# Prefix key
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Basic settings
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",*256col*:Tc"
set -g mouse on
set -g history-limit 50000
set -g display-time 4000
set -g status-interval 5
set -g focus-events on
set -g aggressive-resize on
setw -g mode-keys vi
# Start windows and panes at 1
set -g base-index 1
setw -g pane-base-index 1
# Automatic renumbering
set -g renumber-windows on
# Split panes using | and -
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %
# New window in current path
bind c new-window -c "#{pane_current_path}"
# Reload config
bind r source-file ~/.tmux.conf \; display-message "Config reloaded!"
# Vim-style pane navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Pane resizing
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# Window navigation
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
# Copy mode
bind Enter copy-mode
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel
bind -T copy-mode-vi r send-keys -X rectangle-toggle
# Status bar
set -g status-position top
set -g status-style 'bg=#333333 fg=#5eacd3'
set -g status-left '#[fg=green]#S '
set -g status-right '#[fg=yellow]#(uptime | cut -d "," -f 3-) #[fg=cyan]%Y-%m-%d %H:%M '
set -g status-right-length 50
set -g status-left-length 20
# Window status
setw -g window-status-current-style 'fg=#333333 bg=#5eacd3 bold'
setw -g window-status-current-format ' #I:#W#F '
setw -g window-status-style 'fg=#5eacd3 bg=#333333'
setw -g window-status-format ' #I:#W#F '
# Pane borders
set -g pane-border-style 'fg=#333333'
set -g pane-active-border-style 'fg=#5eacd3'
# Messages
set -g message-style 'fg=yellow bg=#333333 bold'
# Plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'christoomey/vim-tmux-navigator'
# Plugin settings
set -g @resurrect-capture-pane-contents 'on'
set -g @continuum-restore 'on'
set -g @continuum-boot 'on'
# Initialize TPM
run '~/.tmux/plugins/tpm/tpm'
TMUX
# Install TPM
if [ ! -d "$HOME/.tmux/plugins/tpm" ]; then
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
fi
log_info "Tmux configuration created"
}
# Create Neovim configuration
create_neovim_config() {
log_info "Creating Neovim configuration..."
mkdir -p "$HOME/.config/nvim"
cat > "$HOME/.config/nvim/init.vim" << 'NVIM'
" Neovim Configuration - Developer Optimized
" Basic settings
set number relativenumber
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set smartindent
set nowrap
set smartcase
set ignorecase
set noswapfile
set nobackup
set undofile
set undodir=~/.vim/undodir
set incsearch
set termguicolors
set scrolloff=8
set signcolumn=yes
set cmdheight=2
set updatetime=50
set shortmess+=c
set colorcolumn=80
" Plugin manager (vim-plug)
call plug#begin('~/.vim/plugged')
" Essential plugins
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'L3MON4D3/LuaSnip'
Plug 'saadparwaiz1/cmp_luasnip'
Plug 'rafamadriz/friendly-snippets'
" UI enhancements
Plug 'gruvbox-community/gruvbox'
Plug 'nvim-lualine/lualine.nvim'
Plug 'kyazdani42/nvim-web-devicons'
Plug 'nvim-tree/nvim-tree.lua'
" Git integration
Plug 'tpope/vim-fugitive'
Plug 'lewis6991/gitsigns.nvim'
" Productivity
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'jiangmiao/auto-pairs'
Plug 'mg979/vim-visual-multi'
" Language support
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'rust-lang/rust.vim'
Plug 'hashivim/vim-terraform'
call plug#end()
" Color scheme
colorscheme gruvbox
set background=dark
" Key mappings
let mapleader = " "
" File navigation
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
" File tree
nnoremap <leader>e :NvimTreeToggle<CR>
" Window navigation
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Buffer navigation
nnoremap <leader>bn :bnext<CR>
nnoremap <leader>bp :bprevious<CR>
nnoremap <leader>bd :bdelete<CR>
" Git
nnoremap <leader>gs :Git<CR>
nnoremap <leader>gd :Git diff<CR>
nnoremap <leader>gb :Git blame<CR>
" Terminal
nnoremap <leader>t :terminal<CR>
tnoremap <Esc> <C-\><C-n>
" Quick save and quit
nnoremap <leader>w :w<CR>
nnoremap <leader>q :q<CR>
nnoremap <leader>Q :qa!<CR>
" Move lines
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
" Keep cursor centered
nnoremap n nzzzv
nnoremap N Nzzzv
nnoremap J mzJ`z
" Undo break points
inoremap , ,<c-g>u
inoremap . .<c-g>u
inoremap ! !<c-g>u
inoremap ? ?<c-g>u
" Auto commands
augroup AutoSave
autocmd!
autocmd InsertLeave,TextChanged * silent! wall
augroup END
augroup FormatOptions
autocmd!
autocmd BufEnter * setlocal formatoptions-=cro
augroup END
" LSP configuration
lua << EOF
require'lspconfig'.gopls.setup{}
require'lspconfig'.rust_analyzer.setup{}
require'lspconfig'.pyright.setup{}
require'lspconfig'.tsserver.setup{}
EOF
NVIM
# Install vim-plug
curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
log_info "Neovim configuration created"
}
# Create Git configuration
create_git_config() {
log_info "Creating Git configuration..."
cat > "$HOME/.gitconfig" << 'GITCONFIG'
[user]
name = Your Name
email = your.email@example.com
[core]
editor = nvim
whitespace = trailing-space,space-before-tab
pager = delta
[init]
defaultBranch = main
[color]
ui = auto
[alias]
# Status
s = status
st = status --short --branch
# Add
a = add
aa = add --all
ap = add --patch
# Commit
c = commit
cm = commit -m
ca = commit --amend
can = commit --amend --no-edit
# Branch
b = branch
bd = branch -d
bD = branch -D
br = branch --sort=-committerdate --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:green)(%(committerdate:relative))%(color:reset) - %(contents:subject) - %(authorname)'
# Checkout
co = checkout
cob = checkout -b
# Diff
d = diff
dc = diff --cached
ds = diff --stat
# Log
l = log --oneline --graph --decorate
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
ll = log --stat --abbrev-commit
# Push/Pull
p = push
pu = push -u origin HEAD
pl = pull --rebase
# Rebase
rb = rebase
rbi = rebase -i
rbc = rebase --continue
rba = rebase --abort
# Reset
r = reset
rh = reset --hard
rs = reset --soft
# Stash
ss = stash save
sp = stash pop
sl = stash list
sd = stash drop
# Utility
last = log -1 HEAD
unstage = reset HEAD --
discard = checkout --
aliases = config --get-regexp alias
contributors = shortlog --summary --numbered
# Advanced
find-merge = "!sh -c 'commit=$0 && branch=${1:-HEAD} && (git rev-list $commit..$branch --ancestry-path | cat -n; git rev-list $commit..$branch --first-parent | cat -n) | sort -k2 -s | uniq -f1 -d | sort -n | tail -1 | cut -f2'"
show-merge = "!sh -c 'merge=$(git find-merge $0 $1) && [ -n \"$merge\" ] && git show $merge'"
[diff]
tool = nvimdiff
algorithm = histogram
[difftool]
prompt = false
[merge]
tool = nvimdiff
conflictstyle = diff3
[mergetool]
prompt = false
keepBackup = false
[push]
default = current
followTags = true
[pull]
rebase = true
[fetch]
prune = true
[rebase]
autoStash = true
[credential]
helper = cache --timeout=3600
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[interactive]
diffFilter = delta --color-only
[delta]
navigate = true
line-numbers = true
side-by-side = true
[include]
path = ~/.gitconfig.local
GITCONFIG
log_info "Git configuration created"
}
# Main installation flow
main() {
log_info "Starting developer environment setup..."
detect_os
install_dependencies
install_oh_my_zsh
install_starship
create_zsh_config
create_tmux_config
create_neovim_config
create_git_config
# Set Zsh as default shell
if [ "$SHELL" != "$(which zsh)" ]; then
log_info "Setting Zsh as default shell..."
chsh -s $(which zsh)
fi
log_info "Installation complete! Please restart your terminal or run: source ~/.zshrc"
log_info "Don't forget to:"
log_info " 1. Update Git user configuration in ~/.gitconfig"
log_info " 2. Install Neovim plugins: nvim +PlugInstall +qall"
log_info " 3. Install tmux plugins: prefix + I (Ctrl-a + I)"
}
# Run main function
main "$@"
Enterprise Tab Completion Framework
Advanced Completion System
#!/bin/bash
# setup-completions.sh
# Enterprise-grade shell completion configuration
set -euo pipefail
# Install completion frameworks
install_completions() {
echo "Installing advanced completion frameworks..."
# Bash completions
if [[ "$SHELL" == *"bash"* ]]; then
# Install bash-completion
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get install -y bash-completion
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew install bash-completion@2
fi
# Add to bashrc
cat >> ~/.bashrc << 'EOF'
# Bash completion
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
[[ -r "/etc/bash_completion" ]] && . "/etc/bash_completion"
EOF
fi
# Tool-specific completions
setup_kubectl_completion
setup_helm_completion
setup_docker_completion
setup_terraform_completion
setup_aws_completion
}
# Kubectl completion
setup_kubectl_completion() {
echo "Setting up kubectl completion..."
if command -v kubectl &> /dev/null; then
# Zsh
echo 'source <(kubectl completion zsh)' >> ~/.zshrc
echo 'compdef k=kubectl' >> ~/.zshrc
# Bash
echo 'source <(kubectl completion bash)' >> ~/.bashrc
echo 'complete -F __start_kubectl k' >> ~/.bashrc
fi
}
# Helm completion
setup_helm_completion() {
echo "Setting up helm completion..."
if command -v helm &> /dev/null; then
# Zsh
echo 'source <(helm completion zsh)' >> ~/.zshrc
# Bash
echo 'source <(helm completion bash)' >> ~/.bashrc
fi
}
# Docker completion
setup_docker_completion() {
echo "Setting up docker completion..."
if command -v docker &> /dev/null; then
# Docker CLI plugins
mkdir -p ~/.docker/cli-plugins
# Docker compose v2
if ! [ -f ~/.docker/cli-plugins/docker-compose ]; then
curl -SL https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64 \
-o ~/.docker/cli-plugins/docker-compose
chmod +x ~/.docker/cli-plugins/docker-compose
fi
fi
}
# Terraform completion
setup_terraform_completion() {
echo "Setting up terraform completion..."
if command -v terraform &> /dev/null; then
terraform -install-autocomplete 2>/dev/null || true
fi
}
# AWS CLI completion
setup_aws_completion() {
echo "Setting up AWS CLI completion..."
if command -v aws &> /dev/null; then
# Zsh
echo 'autoload bashcompinit && bashcompinit' >> ~/.zshrc
echo 'complete -C aws_completer aws' >> ~/.zshrc
# Bash
echo 'complete -C aws_completer aws' >> ~/.bashrc
fi
}
# Main
install_completions
Intelligent History and Navigation
FZF-Powered History Search
#!/bin/bash
# fzf-enhanced-setup.sh
# Advanced FZF configuration for productivity
# Install FZF with advanced features
install_fzf_enhanced() {
echo "Installing enhanced FZF configuration..."
# Install FZF
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install --all --no-update-rc
# Create advanced FZF configuration
cat > ~/.fzf.advanced << 'FZF_CONFIG'
# Advanced FZF Configuration
# Enhanced default options
export FZF_DEFAULT_OPTS="
--height 40%
--layout=reverse
--border=sharp
--inline-info
--ansi
--color='hl:148,hl+:154,pointer:032,marker:010,bg+:237,gutter:008'
--preview-window='right:60%:wrap'
--bind='ctrl-/:toggle-preview'
--bind='ctrl-y:execute-silent(echo {} | pbcopy)'
--bind='ctrl-e:execute(echo {} | xargs -o vim)'
--bind='ctrl-v:execute(code {})'
"
# File search with preview
export FZF_CTRL_T_OPTS="
--preview 'bat --style=numbers --color=always {} 2>/dev/null || tree -C {} 2>/dev/null'
--preview-window='right:60%:wrap'
"
# Directory navigation
export FZF_ALT_C_OPTS="
--preview 'tree -C {} | head -200'
"
# History search
export FZF_CTRL_R_OPTS="
--preview 'echo {}'
--preview-window='down:3:hidden:wrap'
--bind='?:toggle-preview'
"
# Advanced functions
# Search Git commits
fzf_git_log() {
git log --oneline --color=always |
fzf --ansi --no-sort --reverse --multi --bind 'ctrl-s:toggle-sort' \
--header 'Press CTRL-S to toggle sort' \
--preview 'git show --color=always {1}' \
--preview-window=right:60% |
awk '{print $1}'
}
# Search running processes
fzf_ps() {
ps aux |
fzf --header-lines=1 \
--preview 'echo {}' \
--preview-window=down:3:wrap \
--bind='ctrl-r:reload(ps aux)' |
awk '{print $2}'
}
# Search Docker containers
fzf_docker() {
docker ps -a |
fzf --header-lines=1 \
--preview 'docker logs --tail=50 {1}' \
--preview-window=right:60% |
awk '{print $1}'
}
# Search and install packages
fzf_install() {
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
apt-cache search . |
fzf --multi --preview 'apt-cache show {1}' \
--preview-window=right:60% |
xargs -r sudo apt-get install -y
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew search . |
fzf --multi --preview 'brew info {1}' \
--preview-window=right:60% |
xargs -r brew install
fi
}
# Interactive branch checkout
fzf_checkout() {
git branch -a |
fzf --preview 'git log --oneline --graph --color=always {1}' \
--preview-window=right:60% |
sed 's/^[* ]*//' |
xargs git checkout
}
# Find and kill process
fzf_kill() {
ps aux |
fzf --header-lines=1 --multi \
--preview 'echo {}' \
--preview-window=down:3:wrap |
awk '{print $2}' |
xargs kill -9
}
# Aliases for quick access
alias gl='fzf_git_log'
alias fps='fzf_ps'
alias fd='fzf_docker'
alias fi='fzf_install'
alias gco='fzf_checkout'
alias fkill='fzf_kill'
FZF_CONFIG
# Add to shell configuration
echo "source ~/.fzf.advanced" >> ~/.zshrc
echo "source ~/.fzf.advanced" >> ~/.bashrc
}
# Install additional productivity tools
install_productivity_tools() {
echo "Installing additional productivity tools..."
# Z - directory jumper
git clone https://github.com/rupa/z.git ~/.z
echo ". ~/.z/z.sh" >> ~/.zshrc
echo ". ~/.z/z.sh" >> ~/.bashrc
# Autojump
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get install -y autojump
echo ". /usr/share/autojump/autojump.sh" >> ~/.bashrc
echo ". /usr/share/autojump/autojump.zsh" >> ~/.zshrc
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew install autojump
echo "[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh" >> ~/.zshrc
fi
# McFly - intelligent command history
curl -LSfs https://raw.githubusercontent.com/cantino/mcfly/master/ci/install.sh | sh -s -- --git cantino/mcfly
echo 'eval "$(mcfly init zsh)"' >> ~/.zshrc
echo 'eval "$(mcfly init bash)"' >> ~/.bashrc
}
# Main
install_fzf_enhanced
install_productivity_tools
IDE and Editor Optimization
VS Code Settings for Maximum Productivity
{
"// settings.json": "VS Code productivity configuration",
"editor.fontSize": 14,
"editor.fontFamily": "'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace",
"editor.fontLigatures": true,
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.detectIndentation": true,
"editor.wordWrap": "off",
"editor.minimap.enabled": true,
"editor.renderWhitespace": "trailing",
"editor.suggestSelection": "first",
"editor.acceptSuggestionOnCommitCharacter": true,
"editor.snippetSuggestions": "top",
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.fixAll": true
},
"terminal.integrated.fontSize": 13,
"terminal.integrated.fontFamily": "'JetBrains Mono', monospace",
"terminal.integrated.copyOnSelection": true,
"terminal.integrated.cursorBlinking": true,
"terminal.integrated.cursorStyle": "line",
"terminal.integrated.scrollback": 10000,
"workbench.colorTheme": "One Dark Pro",
"workbench.iconTheme": "material-icon-theme",
"workbench.editor.enablePreview": false,
"workbench.editor.showTabs": true,
"workbench.editor.tabCloseButton": "right",
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000,
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"git.autofetch": true,
"git.confirmSync": false,
"git.enableSmartCommit": true,
"git.postCommitCommand": "push",
"extensions.autoCheckUpdates": true,
"extensions.autoUpdate": true,
"vim.useSystemClipboard": true,
"vim.hlsearch": true,
"vim.incsearch": true,
"vim.useCtrlKeys": true,
"vim.leader": "<space>",
"go.formatTool": "goimports",
"go.lintOnSave": "package",
"go.useLanguageServer": true,
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.provider": "black",
"python.formatting.blackArgs": ["--line-length", "88"],
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[yaml]": {
"editor.defaultFormatter": "redhat.vscode-yaml"
},
"[markdown]": {
"editor.defaultFormatter": "yzhang.markdown-all-in-one"
}
}
Performance Monitoring and Optimization
Shell Startup Performance Analysis
#!/bin/bash
# shell-performance-analyzer.sh
# Analyze and optimize shell startup time
analyze_shell_performance() {
echo "Analyzing shell startup performance..."
# Zsh profiling
cat > ~/.zshrc.profiling << 'EOF'
# Add to beginning of .zshrc
zmodload zsh/zprof
# Your existing .zshrc content here
source ~/.zshrc.original
# Add to end of .zshrc
zprof
EOF
# Bash profiling
cat > ~/.bashrc.profiling << 'EOF'
# Add to beginning of .bashrc
PS4='+ $(date "+%s.%N") $(printf "%*s" $((BASH_SUBSHELL+SHLVL)) "" | tr " " "+") ${BASH_SOURCE[0]##*/}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
exec 3>&2 2>/tmp/bashstart.$$.log
set -x
# Your existing .bashrc content here
source ~/.bashrc.original
# Add to end of .bashrc
set +x
exec 2>&3 3>&-
EOF
echo "Run 'zsh -i -c exit' to profile Zsh startup"
echo "Run 'bash -i -c exit' to profile Bash startup"
echo "Check /tmp/bashstart.*.log for Bash profiling results"
}
# Optimize slow components
optimize_shell_startup() {
echo "Optimizing shell startup..."
# Lazy load NVM
cat >> ~/.zshrc << 'EOF'
# Lazy load NVM for faster startup
export NVM_DIR="$HOME/.nvm"
nvm() {
unset -f nvm
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm "$@"
}
EOF
# Lazy load rbenv
cat >> ~/.zshrc << 'EOF'
# Lazy load rbenv
rbenv() {
unset -f rbenv
eval "$(command rbenv init -)"
rbenv "$@"
}
EOF
# Compile zsh completion dump
if [ -f ~/.zcompdump ]; then
rm -f ~/.zcompdump
compinit -d ~/.zcompdump
zcompile ~/.zcompdump
fi
}
# Main
analyze_shell_performance
optimize_shell_startup
This comprehensive guide provides enterprise teams with production-ready patterns for optimizing developer productivity through terminal configuration, ensuring efficient workflows and reduced friction in daily development tasks.