diff --git a/.zshrc b/.zshrc index 64de85e..6510d44 100644 --- a/.zshrc +++ b/.zshrc @@ -1,149 +1,15 @@ -# Amazon Q pre block. Keep at the top of this file. -[[ -f "${HOME}/Library/Application Support/amazon-q/shell/zshrc.pre.zsh" ]] && builtin source "${HOME}/Library/Application Support/amazon-q/shell/zshrc.pre.zsh" -# Q pre block. Keep at the top of this file. -# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. -# Initialization code that may require console input (password prompts, [y/n] -# confirmations, etc.) must go above this block; everything else may go below. +# Main .zshrc file that sources all modular components -# Variables & Assignments -eval "$(oh-my-posh init zsh --config ~/.oh-my-posh-theme.json)" +# Source plugin initializations (keep at top) +source ~/.oh-my-posh-theme.json +source ~/zsh/plugins.zsh -export KUBE_EDITOR="nvim" -export VISUAL=nvim +# Source all modular files in appropriate order +source ~/zsh/exports.zsh +source ~/zsh/aliases.zsh +source ~/zsh/functions.zsh +source ~/zsh/path.zsh +source ~/zsh/options.zsh +source ~/zsh/keybindings.zsh -# Aliases -alias ls="nu -c ls" -alias la="nu -c 'ls -la'" -alias run="sdlc run" -alias tst="sdlc test" -alias build="sdlc build" -alias vim=nvim -alias vi=nvim -alias update="brew upgrade && brew upgrade" -alias k=kubectl -alias kgs="kubectl get services" -alias kgp="kubectl get pods" -alias kgd="kubectl get deployments" -alias ka="kubectl apply -f" -alias kd="kubectl delete" -alias pull="git pull" -alias g="git" -alias gc="git checkout" -alias ..="cd ../" -alias cls='clear' -alias tf=terraform -alias tfp="terraform plan" -alias tfa="tf apply" -alias rmDir="rm -rf $1" -alias gwp="cd ~/Personal/Golang" # Golang workspace -alias h="cd ~/" - -# Improved Functions -commit() { - if [[ -z "$1" ]]; then - echo "Error: missing 'commit message'" - echo "Usage: commit [-p] [branch]" - return 1 - else - git add . - git commit -m "$1" - if [[ "$2" == "-p" ]]; then - if [[ -z "$3" ]]; then - git push origin "$(git rev-parse --abbrev-ref HEAD)" - else - git push origin "$3" - fi - fi - fi -} - -# Enhanced yazi function with error handling -y() { - if ! command -v yazi >/dev/null 2>&1; then - echo "Error: yazi is not installed" - return 1 - fi - - local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd - yazi "$@" --cwd-file="$tmp" - - if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then - builtin cd -- "$cwd" - fi - - rm -f -- "$tmp" -} - -ustart() { - echo "Spinning Up Ubuntu VM..." - if ! command -v multipass >/dev/null 2>&1; then - echo "Error: multipass is not installed" - return 1 - fi - - multipass launch -n ubuntu --cpus 4 --disk 20G --memory 2G --cloud-init ~/cloud-init.yaml - multipass shell ubuntu -} - -uend() { - echo "Tearing Down Ubuntu VM..." - if ! command -v multipass >/dev/null 2>&1; then - echo "Error: multipass is not installed" - return 1 - fi - - multipass delete ubuntu - multipass purge -} - -# New utility functions -backup() { - if [[ -z "$1" ]]; then - echo "Error: missing filename" - echo "Usage: backup " - return 1 - fi - - if [[ ! -f "$1" ]]; then - echo "Error: '$1' is not a file" - return 1 - fi - - cp "$1" "$1.backup.$(date +%Y%m%d%H%M%S)" - echo "Backup created: $1.backup.$(date +%Y%m%d%H%M%S)" -} - -# Enhanced navigation functions -mkcd() { - if [[ -z "$1" ]]; then - echo "Error: missing directory name" - echo "Usage: mkcd " - return 1 - fi - - mkdir -p "$1" && cd "$1" -} - -# System information function -sysinfo() { - echo "=== System Information ===" - echo "OS: $(uname -s)" - echo "Kernel: $(uname -r)" - echo "Architecture: $(uname -m)" - echo "Uptime: $(uptime)" - echo "Load Average: $(uptime | awk -F'load averages:' '{print $2}')" - echo "Memory Usage: $(free -h | grep Mem | awk '{print $3 "/" $2}')" - echo "Disk Usage: $(df -h / | tail -1 | awk '{print $3 "/" $2}')" -} - -# set language -export LANG=en_US.UTF-8 - -# neofetch moved to function for on-demand execution -alias nf=neofetch - -# Q post block. Keep at the bottom of this file. -test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh" - -# Amazon Q post block. Keep at the bottom of this file. -[[ -f "${HOME}/Library/Application Support/amazon-q/shell/zshrc.post.zsh" ]] && builtin source "${HOME}/Library/Application Support/amazon-q/shell/zshrc.post.zsh" \ No newline at end of file +# Additional configurations can be added here as needed \ No newline at end of file diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh new file mode 100644 index 0000000..429af28 --- /dev/null +++ b/zsh/aliases.zsh @@ -0,0 +1,26 @@ +# Aliases +alias ls="nu -c ls" +alias la="nu -c 'ls -la'" +alias run="sdlc run" +alias tst="sdlc test" +alias build="sdlc build" +alias vim=nvim +alias vi=nvim +alias update="brew upgrade && brew upgrade" +alias k=kubectl +alias kgs="kubectl get services" +alias kgp="kubectl get pods" +alias kgd="kubectl get deployments" +alias ka="kubectl apply -f" +alias kd="kubectl delete" +alias pull="git pull" +alias g="git" +alias gc="git checkout" +alias ..="cd ../" +alias cls='clear' +alias tf=terraform +alias tfp="terraform plan" +alias tfa="tf apply" +alias gwp="cd ~/Personal/Golang" # Golang workspace +alias h="cd ~/" +alias nf=neofetch \ No newline at end of file diff --git a/zsh/exports.zsh b/zsh/exports.zsh new file mode 100644 index 0000000..16f798c --- /dev/null +++ b/zsh/exports.zsh @@ -0,0 +1,4 @@ +# Environment variable exports +export KUBE_EDITOR="nvim" +export VISUAL=nvim +export LANG=en_US.UTF-8 \ No newline at end of file diff --git a/zsh/functions.zsh b/zsh/functions.zsh new file mode 100644 index 0000000..488d955 --- /dev/null +++ b/zsh/functions.zsh @@ -0,0 +1,111 @@ +# Improved Functions + +# Commit function with optional push +commit() { + if [[ -z "$1" ]]; then + echo "Error: missing 'commit message'" + echo "Usage: commit [-p] [branch]" + return 1 + else + git add . + git commit -m "$1" + if [[ "$2" == "-p" ]]; then + if [[ -z "$3" ]]; then + git push origin "$(git rev-parse --abbrev-ref HEAD)" + else + git push origin "$3" + fi + fi + fi +} + +# Enhanced yazi function with error handling +y() { + if ! command -v yazi >/dev/null 2>&1; then + echo "Error: yazi is not installed" + return 1 + fi + + local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd + yazi "$@" --cwd-file="$tmp" + + if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then + builtin cd -- "$cwd" + fi + + rm -f -- "$tmp" +} + +# Start Ubuntu VM with multipass +ustart() { + echo "Spinning Up Ubuntu VM..." + if ! command -v multipass >/dev/null 2>&1; then + echo "Error: multipass is not installed" + return 1 + fi + + multipass launch -n ubuntu --cpus 4 --disk 20G --memory 2G --cloud-init ~/cloud-init.yaml + multipass shell ubuntu +} + +# End Ubuntu VM with multipass +uend() { + echo "Tearing Down Ubuntu VM..." + if ! command -v multipass >/dev/null 2>&1; then + echo "Error: multipass is not installed" + return 1 + fi + + multipass delete ubuntu + multipass purge +} + +# Backup function +backup() { + if [[ -z "$1" ]]; then + echo "Error: missing filename" + echo "Usage: backup " + return 1 + fi + + if [[ ! -f "$1" ]]; then + echo "Error: '$1' is not a file" + return 1 + fi + + cp "$1" "$1.backup.$(date +%Y%m%d%H%M%S)" + echo "Backup created: $1.backup.$(date +%Y%m%d%H%M%S)" +} + +# Create directory and cd into it +mkcd() { + if [[ -z "$1" ]]; then + echo "Error: missing directory name" + echo "Usage: mkcd " + return 1 + fi + + mkdir -p "$1" && cd "$1" +} + +# System information function +sysinfo() { + echo "=== System Information ===" + echo "OS: $(uname -s)" + echo "Kernel: $(uname -r)" + echo "Architecture: $(uname -m)" + echo "Uptime: $(uptime)" + echo "Load Average: $(uptime | awk -F'load averages:' '{print $2}')" + echo "Memory Usage: $(free -h | grep Mem | awk '{print $3 "/" $2}')" + echo "Disk Usage: $(df -h / | tail -1 | awk '{print $3 "/" $2}')" +} + +# Fixed rmDir as a function instead of alias +rmDir() { + if [[ -z "$1" ]]; then + echo "Error: missing directory name" + echo "Usage: rmDir " + return 1 + fi + rm -rf "$1" +} \ No newline at end of file diff --git a/zsh/keybindings.zsh b/zsh/keybindings.zsh new file mode 100644 index 0000000..25d4c59 --- /dev/null +++ b/zsh/keybindings.zsh @@ -0,0 +1,3 @@ +# Key bindings +# Currently no specific key bindings in the original .zshrc +# This file is reserved for future key bindings \ No newline at end of file diff --git a/zsh/options.zsh b/zsh/options.zsh new file mode 100644 index 0000000..28b4ecc --- /dev/null +++ b/zsh/options.zsh @@ -0,0 +1,3 @@ +# Shell options and settings +# Currently no specific setopt commands in the original .zshrc +# This file is reserved for future shell options \ No newline at end of file diff --git a/zsh/path.zsh b/zsh/path.zsh new file mode 100644 index 0000000..60a98c4 --- /dev/null +++ b/zsh/path.zsh @@ -0,0 +1,3 @@ +# PATH-related configuration +# Currently no specific PATH modifications in the original .zshrc +# This file is reserved for future PATH configurations \ No newline at end of file diff --git a/zsh/plugins.zsh b/zsh/plugins.zsh new file mode 100644 index 0000000..eb79bf5 --- /dev/null +++ b/zsh/plugins.zsh @@ -0,0 +1,16 @@ +# Plugin initialization +eval "$(oh-my-posh init zsh --config ~/.oh-my-posh-theme.json)" + +# Amazon Q pre block. Keep at the top of this file. +[[ -f "${HOME}/Library/Application Support/amazon-q/shell/zshrc.pre.zsh" ]] && builtin source "${HOME}/Library/Application Support/amazon-q/shell/zshrc.pre.zsh" + +# Q pre block. Keep at the top of this file. +# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. +# Initialization code that may require console input (password prompts, [y/n] +# confirmations, etc.) must go above this block; everything else may go below. + +# Q post block. Keep at the bottom of this file. +test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh" + +# Amazon Q post block. Keep at the bottom of this file. +[[ -f "${HOME}/Library/Application Support/amazon-q/shell/zshrc.post.zsh" ]] && builtin source "${HOME}/Library/Application Support/amazon-q/shell/zshrc.post.zsh" \ No newline at end of file