init
This commit is contained in:
commit
b4cdb80b5c
137 changed files with 6383 additions and 0 deletions
4
zsh/.config/zsh/.zshenv
Normal file
4
zsh/.config/zsh/.zshenv
Normal file
|
@ -0,0 +1,4 @@
|
|||
source ~/.config/env
|
||||
|
||||
# If running from tty1 start sway
|
||||
[ "$(tty)" = "/dev/tty1" ] && exec dbus-run-session sway
|
9
zsh/.config/zsh/.zshrc
Normal file
9
zsh/.config/zsh/.zshrc
Normal file
|
@ -0,0 +1,9 @@
|
|||
source $ZDOTDIR/init.zsh
|
||||
|
||||
# Initialize completions with defer
|
||||
autoload -Uz compinit
|
||||
if [ "$(date +'%j')" != "$(stat -f '%Sm' -t '%j' ~/.zcompdump 2>/dev/null)" ]; then
|
||||
zsh-defer compinit
|
||||
else
|
||||
zsh-defer compinit -C
|
||||
fi
|
95
zsh/.config/zsh/alias.zsh
Normal file
95
zsh/.config/zsh/alias.zsh
Normal file
|
@ -0,0 +1,95 @@
|
|||
# Package management
|
||||
alias fly='flyctl'
|
||||
alias yay="paru --bottomup"
|
||||
alias yeet="sudo pacman -Rns"
|
||||
alias orphan="doas pacman -Rns (pacman -Qtdq)"
|
||||
|
||||
# Navigation shortcuts
|
||||
alias dc="cd"
|
||||
alias gD="cd ~/Desktop"
|
||||
alias gd="cd ~/Downloads"
|
||||
alias gr="cd ~/Development/"
|
||||
alias gs="cd ~/Sync"
|
||||
alias gdot="cd ~/dotfiles"
|
||||
alias gkey="cd ~/.local/share/keyrings/"
|
||||
alias gt="cd ~/Dev/"
|
||||
alias gpi='cd ~/Development/pi'
|
||||
alias gtt='cd ~/Development/tecnologo'
|
||||
alias nubceo='cd ~/Development/nubceo'
|
||||
alias vairix='cd ~/Development/vairix'
|
||||
alias seekr='cd ~/Development/seekr'
|
||||
|
||||
# File operations/utilities
|
||||
alias df="duf"
|
||||
alias mkdir="mkdir -pv"
|
||||
alias chmox="chmod +x"
|
||||
alias lf="yazi"
|
||||
alias slides=presenterm
|
||||
alias lll='ls -l `find . -maxdepth 1 -type l -print`'
|
||||
alias syncRepo="git fetch --all; git reset --hard origin/master"
|
||||
|
||||
# System commands
|
||||
alias src='exec zsh'
|
||||
alias k="kubectl"
|
||||
alias ks="kubens"
|
||||
alias kx="kubectx"
|
||||
alias yta="youtube-dl --add-metadata -xic"
|
||||
|
||||
# Development tools
|
||||
alias vim='nvim'
|
||||
alias v='vim'
|
||||
alias tf='terraform'
|
||||
alias g='git'
|
||||
alias gho="gh browse"
|
||||
alias gh-clone='gc'
|
||||
alias task='go-task'
|
||||
alias sdu='sdm-ui fzf'
|
||||
alias fd='/bin/fd'
|
||||
|
||||
|
||||
# Tmux
|
||||
alias tmux='TERM=xterm-256color tmux -f "$XDG_CONFIG_HOME"/tmux/tmux.conf'
|
||||
alias ts="tmux ls"
|
||||
alias ta="tmux attach -t default || tmux new -s default"
|
||||
|
||||
# Configuration editing shortcuts
|
||||
alias tmuxrc="vim $XDG_CONFIG_HOME/tmux/tmux.conf"
|
||||
alias doomconf="vim ~/.config/gzdoom/gzdoom.ini"
|
||||
alias pluginconf="vim ~/.config/nvim/plugins.vim"
|
||||
alias i3conf="vim ~/.config/i3/config"
|
||||
alias cssh="vim ~/.ssh/config"
|
||||
alias vd='vim -c ":VimwikiMakeDiaryNote"'
|
||||
alias vw='vim -c ":VimwikiIndex"'
|
||||
|
||||
# Clipboard operations - with auto-detection
|
||||
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
|
||||
alias copy="wl-copy"
|
||||
alias paste="wl-paste"
|
||||
else
|
||||
alias copy="xclip -selection clipboard"
|
||||
alias paste="xclip -selection clipboard -o"
|
||||
fi
|
||||
|
||||
# Work related
|
||||
alias sstack='cd ~/Dev/stuzo/oc-docker-compose; docker-compose up postgres redis rabbitmq'
|
||||
|
||||
# Chezmoi shorthand
|
||||
alias ch='chezmoi'
|
||||
|
||||
# Aesthetics
|
||||
alias next='feh --no-fehbg -z --bg-scale ~/Pictures/*'
|
||||
|
||||
command -v eza >/dev/null 2>&1 || { echo "ERROR: 'eza' not found"; return; }
|
||||
|
||||
# Set up aliases with 'eza'
|
||||
alias ls='eza --group-directories-first --icons=always'
|
||||
|
||||
# Use '--git' flag if supported
|
||||
if eza --version | grep -q '+git'; then
|
||||
alias ll='ls -lh --git'
|
||||
else
|
||||
alias ll='ls -lh'
|
||||
fi
|
||||
|
||||
alias la='ll -a'
|
||||
alias tree='ll --tree --level=2'
|
293
zsh/.config/zsh/functions.zsh
Normal file
293
zsh/.config/zsh/functions.zsh
Normal file
|
@ -0,0 +1,293 @@
|
|||
# Lazy load zoxide
|
||||
z() {
|
||||
# Remove the placeholder function
|
||||
unfunction "$0"
|
||||
|
||||
# Load zoxide
|
||||
eval "$(zoxide init zsh)"
|
||||
|
||||
# Execute the command
|
||||
$0 "$@"
|
||||
}
|
||||
|
||||
# Ensure we have all the zoxide command variants covered
|
||||
zi() { z "$@" }
|
||||
za() { z "$@" }
|
||||
zrm() { zoxide remove "$@" }
|
||||
|
||||
function _package_manager {
|
||||
local pkg_manager=""
|
||||
if [[ -f bun.lockb ]]; then
|
||||
pkg_manager="bun"
|
||||
elif [[ -f pnpm-lock.yaml ]]; then
|
||||
pkg_manager="pnpm"
|
||||
elif [[ -f yarn.lock ]]; then
|
||||
pkg_manager="yarn"
|
||||
elif [[ -f package-lock.json ]]; then
|
||||
pkg_manager="npm"
|
||||
else
|
||||
pkg_manager="pnpm"
|
||||
fi
|
||||
|
||||
# Check if the first argument is a script in package.json
|
||||
if [[ -f package.json ]] && [[ $1 != "run" ]] && [[ $1 != "install" ]] && [[ $1 != "add" ]] && [[ $1 != "remove" ]] && [[ $1 != "i" ]] && [[ $1 != "rm" ]]; then
|
||||
# Check if the command exists in package.json scripts using jq
|
||||
if jq -e ".scripts[\"$1\"] != null" package.json >/dev/null 2>&1; then
|
||||
set -- "run" "$@"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Use corepack when available
|
||||
if command -v corepack >/dev/null 2>&1; then
|
||||
corepack ${pkg_manager} "$@"
|
||||
else
|
||||
command ${pkg_manager} "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
yarn() { echo 🖕; }
|
||||
yarnpkg() { echo 🖕; }
|
||||
pnpm() { echo 🖕; }
|
||||
pn() { echo 🖕; }
|
||||
pnpx() { echo 🖕; }
|
||||
npm() { echo 🖕; }
|
||||
|
||||
alias p='_package_manager'
|
||||
|
||||
alias unChonk="echo '🧹 Starting the great node_modules purge...' && find . -name 'node_modules' -type d -prune -exec sh -c 'echo \"💥 Deleting {}\" && rm -rf \"{}\"' \;"
|
||||
|
||||
# Open files using system default application
|
||||
function open {
|
||||
for i in $*
|
||||
do
|
||||
setsid nohup xdg-open $i > /dev/null 2> /dev/null
|
||||
done
|
||||
}
|
||||
|
||||
function upload_file() {
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "Usage: $0 <file>"
|
||||
return 1
|
||||
fi
|
||||
if [[ ! -f "$1" ]]; then
|
||||
echo "Error: File not found: $1"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# local url="https://dump.mz.uy"
|
||||
local url="http://localhost:8080"
|
||||
echo "Uploading $1 to $url..."
|
||||
local full_response=$(curl -i -F"file=@$1" -F"one_time=" "$url")
|
||||
local url_response=$(echo "$full_response" | tail -n 1)
|
||||
local token=$(echo "$full_response" | grep -i "X-Token:" | awk '{print $2}' | tr -d '\r')
|
||||
|
||||
if [[ -n "$url_response" ]]; then
|
||||
echo -n "$url_response" | wl-copy # Wayland
|
||||
echo "✓ Uploaded: $url_response (copied to clipboard)"
|
||||
|
||||
if [[ -n "$token" ]]; then
|
||||
echo "Management token: $token"
|
||||
fi
|
||||
else
|
||||
echo "× Failed to upload file"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Create both commands as aliases to the same function
|
||||
alias drop='upload_file'
|
||||
alias dump='upload_file'
|
||||
|
||||
|
||||
# Wacom tablet configuration
|
||||
function wacom {
|
||||
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
|
||||
systemctl --user enable opentabletdriver --now
|
||||
otd loadsettings ~/Sync/wacom/wacom.json
|
||||
else
|
||||
# Reset area and map the stylus to DisplayPort-0, then rotate
|
||||
xsetwacom --set "Wacom One by Wacom S Pen stylus" ResetArea
|
||||
xsetwacom --set "Wacom One by Wacom S Pen stylus" MapToOutput DisplayPort-0
|
||||
xsetwacom --set "Wacom One by Wacom S Pen stylus" Rotate half
|
||||
|
||||
# Reset area and map the eraser to DisplayPort-0
|
||||
xsetwacom --set "Wacom One by Wacom S Pen eraser" ResetArea
|
||||
xsetwacom --set "Wacom One by Wacom S Pen eraser" MapToOutput DisplayPort-0
|
||||
fi
|
||||
}
|
||||
|
||||
# Enhanced git clone function
|
||||
function gc {
|
||||
if [[ "$1" == */* ]]
|
||||
then
|
||||
git clone "https://github.com/$1" "${@:2}"
|
||||
else
|
||||
git clone "https://github.com/marianozunino/$1" "${@:2}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Improved file sharing with croc
|
||||
function croc-send {
|
||||
croc send --code mzunino "$@"
|
||||
}
|
||||
|
||||
function croc-receive {
|
||||
croc --yes mzunino
|
||||
}
|
||||
|
||||
# Fix swaymsg when inside tmux
|
||||
if [[ -v TMUX ]]; then
|
||||
function swaymsg {
|
||||
export SWAYSOCK=$XDG_RUNTIME_DIR/sway-ipc.$UID.$(pgrep -x sway).sock
|
||||
command swaymsg "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
# Expose local port to internet
|
||||
function expose() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: expose <port>"
|
||||
return
|
||||
fi
|
||||
ssh marianozunino@srv.us -R 1:localhost:$1
|
||||
}
|
||||
|
||||
# Helper function for command existence check
|
||||
function _has {
|
||||
return $( whence $1 >/dev/null )
|
||||
}
|
||||
|
||||
# Sublime merge shortcut
|
||||
function sm {
|
||||
/opt/sublime_merge/sublime_merge $1
|
||||
}
|
||||
|
||||
# Edit nvim config
|
||||
function vimrc {
|
||||
cd $XDG_CONFIG_HOME/nvim
|
||||
nvim
|
||||
cd -
|
||||
}
|
||||
|
||||
# Edit zsh config
|
||||
function zshrc {
|
||||
cd $XDG_CONFIG_HOME/zsh
|
||||
nvim
|
||||
cd -
|
||||
}
|
||||
|
||||
# Find process using a port
|
||||
function ppid {
|
||||
lsof -i :$1
|
||||
}
|
||||
|
||||
alias pport=ppid
|
||||
|
||||
# Kubernetes port forwarding helper
|
||||
function kf {
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: kf <cluster> [service-name]"
|
||||
return
|
||||
fi
|
||||
|
||||
local namespace="oc-app"
|
||||
local cluster="oc-$1-eks-cluster"
|
||||
local svc_filter=""
|
||||
|
||||
if [ ! -z "$2" ]; then
|
||||
svc_filter="-l app.kubernetes.io/instance=$2"
|
||||
fi
|
||||
|
||||
sudo -E kubefwd svc -n ${namespace} -x ${cluster} ${svc_filter}
|
||||
}
|
||||
|
||||
function cat {
|
||||
if [ -n "$SSH_TTY" ] || [ -n "$SSH_CLIENT" ] || [ -n "$SSH_CONNECTION" ]; then
|
||||
bat --plain --paging=never "$@"
|
||||
else
|
||||
bat "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# Enhanced PrivateBin sharing function
|
||||
function pb {
|
||||
local usage="Usage: pb [-b] [-e <expiration>] <file>"
|
||||
local burn_after_reading=false
|
||||
local expiration="1week"
|
||||
|
||||
while getopts ":be:" opt; do
|
||||
case ${opt} in
|
||||
b )
|
||||
burn_after_reading=true
|
||||
;;
|
||||
e )
|
||||
expiration=$OPTARG
|
||||
;;
|
||||
\? )
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
echo $usage
|
||||
return 1
|
||||
;;
|
||||
: )
|
||||
echo "Option -$OPTARG requires an argument." >&2
|
||||
echo $usage
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND -1))
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo $usage
|
||||
return 1
|
||||
fi
|
||||
|
||||
local file=$1
|
||||
if [ ! -f "$file" ]; then
|
||||
echo "Error: File '$file' not found." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check for required commands
|
||||
for cmd in privatebin wl-copy; do
|
||||
if ! command -v $cmd &> /dev/null; then
|
||||
echo "Error: '$cmd' command not found. Please install it." >&2
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Prepare the command
|
||||
local cmd="privatebin create --filename $file --expire $expiration"
|
||||
if $burn_after_reading; then
|
||||
cmd="$cmd --burn-after-reading"
|
||||
fi
|
||||
|
||||
# Run command and handle result
|
||||
local result
|
||||
result=$(eval "$cmd" 2>&1)
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to upload file to PrivateBin. Details:" >&2
|
||||
echo "$result" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo $result
|
||||
echo "$result" | wl-copy
|
||||
echo "PrivateBin link copied to clipboard."
|
||||
notify-send "PrivateBin" "Link copied to clipboard" 2>/dev/null || true
|
||||
}
|
||||
|
||||
# Load autocomplete files
|
||||
for completion_file in ~/.local/share/zsh/*-autocomplete.zsh; do
|
||||
if [ -f "$completion_file" ]; then
|
||||
source "$completion_file"
|
||||
fi
|
||||
done
|
||||
|
||||
# Initialize completions for common tools
|
||||
if command -v rop &> /dev/null; then eval "$(rop completion zsh)"; fi
|
||||
if command -v goq &> /dev/null; then eval "$(goq completion zsh)"; fi
|
||||
if command -v kubefwd &> /dev/null; then eval "$(kubefwd completion zsh)"; fi
|
||||
if command -v bombadil &> /dev/null; then eval "$(bombadil generate-completions zsh)"; fi
|
||||
if command -v eza &> /dev/null; then compdef eza=ls; fi
|
||||
|
56
zsh/.config/zsh/init.zsh
Normal file
56
zsh/.config/zsh/init.zsh
Normal file
|
@ -0,0 +1,56 @@
|
|||
PLUGIN_DIR="$HOME/.local/share/zsh/plugins"
|
||||
PLUGIN_LOCK="$PLUGIN_DIR/.plugins.lock"
|
||||
[ -d "$PLUGIN_DIR" ] || mkdir -p "$PLUGIN_DIR"
|
||||
|
||||
# Reinstall function
|
||||
update-plugins() {
|
||||
rm -fr "$PLUGIN_DIR"
|
||||
echo "Plugin lock removed. Restart your shell to reinstall plugins."
|
||||
}
|
||||
|
||||
# Define plugins: "github_repo name"
|
||||
plugins=(
|
||||
"romkatv/zsh-defer"
|
||||
"zsh-users/zsh-autosuggestions"
|
||||
"hlissner/zsh-autopair"
|
||||
"zsh-users/zsh-history-substring-search"
|
||||
"Aloxaf/fzf-tab"
|
||||
"junegunn/fzf"
|
||||
"subnixr/minimal"
|
||||
"zap-zsh/vim"
|
||||
"zsh-users/zsh-syntax-highlighting"
|
||||
)
|
||||
|
||||
# Only install plugins if lock file doesn't exist
|
||||
if [ ! -f "$PLUGIN_LOCK" ]; then
|
||||
for plugin in "${plugins[@]}"; do
|
||||
plugin_name=${plugin##*/}
|
||||
if [ ! -d "$PLUGIN_DIR/$plugin_name" ]; then
|
||||
echo "Installing $plugin_name"
|
||||
git clone --quiet "https://github.com/$plugin" "$PLUGIN_DIR/$plugin_name" --depth=1
|
||||
fi
|
||||
done
|
||||
date > "$PLUGIN_LOCK"
|
||||
fi
|
||||
|
||||
# Source plugins
|
||||
source "$PLUGIN_DIR/zsh-defer/zsh-defer.plugin.zsh"
|
||||
source "$PLUGIN_DIR/zsh-autosuggestions/zsh-autosuggestions.zsh"
|
||||
source "$PLUGIN_DIR/zsh-autopair/autopair.zsh"
|
||||
source "$PLUGIN_DIR/zsh-history-substring-search/zsh-history-substring-search.zsh"
|
||||
source "$PLUGIN_DIR/fzf-tab/fzf-tab.plugin.zsh"
|
||||
source "$PLUGIN_DIR/fzf/shell/completion.zsh"
|
||||
source "$PLUGIN_DIR/fzf/shell/key-bindings.zsh"
|
||||
source "$PLUGIN_DIR/minimal/minimal.zsh"
|
||||
source "$PLUGIN_DIR/vim/vim.plugin.zsh"
|
||||
|
||||
# Source config files
|
||||
source "$ZDOTDIR/opts.zsh"
|
||||
source "$ZDOTDIR/rose-pine.sh"
|
||||
source "$ZDOTDIR/maintenance.zsh"
|
||||
|
||||
# Defer loading
|
||||
zsh-defer source "$PLUGIN_DIR/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
|
||||
for config in mise.zsh tmux.zsh functions.zsh alias.zsh keymap.zsh path.zsh pnpm.zsh opts.zsh; do
|
||||
zsh-defer source "$ZDOTDIR/$config"
|
||||
done
|
75
zsh/.config/zsh/keymap.zsh
Normal file
75
zsh/.config/zsh/keymap.zsh
Normal file
|
@ -0,0 +1,75 @@
|
|||
# ===== History Navigation =====
|
||||
# Setup fuzzy history search with up/down keys
|
||||
|
||||
# Up arrow/k - search history forward
|
||||
autoload -U up-line-or-beginning-search
|
||||
zle -N up-line-or-beginning-search
|
||||
|
||||
# Down arrow/j - search history backward
|
||||
autoload -U down-line-or-beginning-search
|
||||
zle -N down-line-or-beginning-search
|
||||
|
||||
# Bind keys in both vicmd and viins modes
|
||||
# vicmd = vi command mode, viins = vi insert mode
|
||||
bindkey -M vicmd "k" up-line-or-beginning-search
|
||||
bindkey -M vicmd "^k" up-line-or-beginning-search
|
||||
bindkey -M viins "^k" up-line-or-beginning-search
|
||||
bindkey -M viins "^[[A" up-line-or-beginning-search # Up arrow key
|
||||
|
||||
bindkey -M vicmd "j" down-line-or-beginning-search
|
||||
bindkey -M vicmd "^j" down-line-or-beginning-search
|
||||
bindkey -M viins "^j" down-line-or-beginning-search
|
||||
bindkey -M viins "^[[B" down-line-or-beginning-search # Down arrow key
|
||||
|
||||
# ===== System Clipboard Integration =====
|
||||
# Enhanced yank that copies to system clipboard
|
||||
|
||||
function vi-yank-clipboard() {
|
||||
# First perform the normal vi-yank operation
|
||||
zle vi-yank
|
||||
|
||||
# Only copy if there's content in the cut buffer
|
||||
if [[ -n "$CUTBUFFER" ]]; then
|
||||
# Detect the environment and use appropriate clipboard command
|
||||
if [[ "$XDG_SESSION_TYPE" == "wayland" ]] && command -v wl-copy >/dev/null; then
|
||||
echo -n "$CUTBUFFER" | wl-copy
|
||||
elif command -v xclip >/dev/null; then
|
||||
echo -n "$CUTBUFFER" | xclip -selection clipboard
|
||||
elif command -v pbcopy >/dev/null; then
|
||||
# For macOS
|
||||
echo -n "$CUTBUFFER" | pbcopy
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Register the function and bind it
|
||||
zle -N vi-yank-clipboard
|
||||
bindkey -M vicmd "y" vi-yank-clipboard
|
||||
|
||||
# ===== Command Line Editing =====
|
||||
# Edit command in external editor
|
||||
|
||||
# Load the function and register it
|
||||
autoload -U edit-command-line
|
||||
zle -N edit-command-line
|
||||
|
||||
# Bind 'v' in command mode to open editor
|
||||
bindkey -M vicmd "v" edit-command-line
|
||||
|
||||
# ===== Additional Useful Bindings =====
|
||||
|
||||
# Ctrl+Space to accept autosuggestion
|
||||
bindkey '^ ' autosuggest-accept
|
||||
|
||||
# Ctrl+e to edit command in editor from any mode
|
||||
bindkey '^e' edit-command-line
|
||||
|
||||
# Ensure backspace and delete work as expected
|
||||
bindkey '^?' backward-delete-char
|
||||
bindkey "^[[3~" delete-char
|
||||
|
||||
# Home/End keys
|
||||
bindkey "^[[H" beginning-of-line
|
||||
bindkey "^[[F" end-of-line
|
||||
bindkey "^[[1~" beginning-of-line
|
||||
bindkey "^[[4~" end-of-line
|
69
zsh/.config/zsh/maintenance.zsh
Normal file
69
zsh/.config/zsh/maintenance.zsh
Normal file
|
@ -0,0 +1,69 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
# Configuration
|
||||
MAINTENANCE_SCRIPT="$HOME/.local/bin/maintenance.sh"
|
||||
TIMESTAMP_FILE="$HOME/.local/share/arch_maintenance_timestamp"
|
||||
INTERVAL=7
|
||||
|
||||
if [ ! -f "$MAINTENANCE_SCRIPT" ]; then
|
||||
echo "Maintenance script not found at $MAINTENANCE_SCRIPT"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ -f "$TIMESTAMP_FILE" ]; then
|
||||
LAST_RUN=$(cat $TIMESTAMP_FILE)
|
||||
CURRENT_TIME=$(date +%s)
|
||||
DAYS_DIFF=$(( (CURRENT_TIME - LAST_RUN) / 86400 ))
|
||||
|
||||
# Return immediately if maintenance not due
|
||||
[ $DAYS_DIFF -lt $INTERVAL ] && return 0
|
||||
else
|
||||
# Create timestamp file if missing (first run)
|
||||
echo $(($(date +%s) - ${INTERVAL}*86400 - 1)) > $TIMESTAMP_FILE
|
||||
DAYS_DIFF=$INTERVAL # Set for first run
|
||||
fi
|
||||
|
||||
# Simple output functions that work with or without gum
|
||||
print_styled() {
|
||||
if command -v gum &> /dev/null; then
|
||||
gum style "$@"
|
||||
else
|
||||
echo "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
ask_confirm() {
|
||||
if command -v gum &> /dev/null; then
|
||||
gum confirm "$1"
|
||||
else
|
||||
echo "$1 (y/n)"
|
||||
read -k 1 REPLY
|
||||
echo ""
|
||||
[[ $REPLY =~ ^[Yy]$ ]]
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to run maintenance script
|
||||
run_maintenance() {
|
||||
print_styled "Running system maintenance script..."
|
||||
|
||||
if sudo $MAINTENANCE_SCRIPT; then
|
||||
date +%s > $TIMESTAMP_FILE
|
||||
print_styled "✓ Maintenance completed successfully."
|
||||
else
|
||||
print_styled "✗ Maintenance script failed. Please check the output and run it manually."
|
||||
fi
|
||||
}
|
||||
|
||||
# Display maintenance notification
|
||||
echo ""
|
||||
print_styled "⚠️ It's been $DAYS_DIFF days since your last system maintenance"
|
||||
|
||||
if ask_confirm "Would you like to run maintenance now?"; then
|
||||
run_maintenance
|
||||
else
|
||||
print_styled "Maintenance skipped. You'll be reminded next time you start your shell."
|
||||
print_styled "To run manually: sudo $MAINTENANCE_SCRIPT"
|
||||
fi
|
||||
|
||||
return 0
|
59
zsh/.config/zsh/mise.zsh
Normal file
59
zsh/.config/zsh/mise.zsh
Normal file
|
@ -0,0 +1,59 @@
|
|||
# Source it
|
||||
eval "$(/home/forbi/.local/bin/mise activate zsh)"
|
||||
|
||||
# Install mise if not present
|
||||
if ! command -v mise &> /dev/null
|
||||
then
|
||||
echo "Installing mise..."
|
||||
mkdir -p ~/.local/bin
|
||||
curl https://mise.jdx.dev/mise-latest-linux-x64 > ~/.local/bin/mise
|
||||
chmod +x ~/.local/bin/mise
|
||||
~/.local/bin/mise install
|
||||
fi
|
||||
|
||||
|
||||
#compdef mise
|
||||
local curcontext="$curcontext"
|
||||
|
||||
# caching config
|
||||
_usage_mise_cache_policy() {
|
||||
if [[ -z "${lifetime}" ]]; then
|
||||
lifetime=$((60*60*4)) # 4 hours
|
||||
fi
|
||||
local -a oldp
|
||||
oldp=( "$1"(Nms+${lifetime}) )
|
||||
(( $#oldp ))
|
||||
}
|
||||
|
||||
_mise() {
|
||||
typeset -A opt_args
|
||||
local curcontext="$curcontext" spec cache_policy
|
||||
|
||||
if ! command -v usage &> /dev/null; then
|
||||
echo >&2
|
||||
echo "Error: usage CLI not found. This is required for completions to work in mise." >&2
|
||||
echo "See https://usage.jdx.dev for more information." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
|
||||
if [[ -z $cache_policy ]]; then
|
||||
zstyle ":completion:${curcontext}:" cache-policy _usage_mise_cache_policy
|
||||
fi
|
||||
|
||||
if ( [[ -z "${_usage_mise_spec:-}" ]] || _cache_invalid _usage_mise_spec ) \
|
||||
&& ! _retrieve_cache _usage_mise_spec;
|
||||
then
|
||||
spec="$(mise usage)"
|
||||
_store_cache _usage_mise_spec spec
|
||||
fi
|
||||
|
||||
_arguments "*: :(($(usage complete-word --shell zsh -s "$spec" -- "${words[@]}" )))"
|
||||
return 0
|
||||
}
|
||||
|
||||
if [ "$funcstack[1]" = "_mise" ]; then
|
||||
_mise "$@"
|
||||
else
|
||||
compdef _mise mise
|
||||
fi
|
34
zsh/.config/zsh/opts.zsh
Normal file
34
zsh/.config/zsh/opts.zsh
Normal file
|
@ -0,0 +1,34 @@
|
|||
# History Config
|
||||
setopt interactivecomments
|
||||
setopt EXTENDED_HISTORY
|
||||
setopt HIST_EXPIRE_DUPS_FIRST
|
||||
setopt HIST_IGNORE_DUPS
|
||||
setopt HIST_IGNORE_ALL_DUPS
|
||||
setopt HIST_IGNORE_SPACE
|
||||
setopt HIST_FIND_NO_DUPS
|
||||
setopt HIST_SAVE_NO_DUPS
|
||||
setopt HIST_BEEP
|
||||
setopt INC_APPEND_HISTORY
|
||||
setopt HIST_FCNTL_LOCK
|
||||
setopt SHARE_HISTORY
|
||||
setopt AUTO_CD
|
||||
|
||||
HISTORY_IGNORE='(*.git/hooks*)'
|
||||
LESSHISTFILE="-"
|
||||
HISTFILE="$ZDOTDIR/zsh_history_$HOST"
|
||||
HISTFILESIZE=100000
|
||||
HISTSIZE=100000
|
||||
SAVEHIST=100000
|
||||
|
||||
MNML_INFOLN=()
|
||||
MNML_PROMPT=(mnml_ssh mnml_status 'mnml_cwd 2 0' mnml_git mnml_keymap )
|
||||
MNML_RPROMPT=()
|
||||
MNML_NORMAL_CHAR="◉"
|
||||
|
||||
# Environment variables
|
||||
export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border'
|
||||
export FZF_DEFAULT_COMMAND='fd --type f'
|
||||
|
||||
export COREPACK_ENABLE_DOWNLOAD_PROMPT=0
|
||||
export COREPACK_ENABLE_NETWORK_RESOLUTION=1
|
||||
export COREPACK_ENABLE_STRICT_VERIFICATION=0
|
37
zsh/.config/zsh/path.zsh
Normal file
37
zsh/.config/zsh/path.zsh
Normal file
|
@ -0,0 +1,37 @@
|
|||
# Efficient PATH management
|
||||
|
||||
function update_path() {
|
||||
# Define directories to add to PATH
|
||||
local dirs=(
|
||||
"/usr/local/texlive/2024/bin/x86_64-linux"
|
||||
"$HOME/.local/bin"
|
||||
"$HOME/.bin"
|
||||
"$HOME/.dotnet/tools"
|
||||
"$HOME/.local/share/npm/bin"
|
||||
"$HOME/.local/share/cargo/bin"
|
||||
)
|
||||
|
||||
# Prepare new PATH variable
|
||||
local new_path=""
|
||||
|
||||
# Add directories if they exist
|
||||
for dir in "${dirs[@]}"; do
|
||||
if [ -d "$dir" ]; then
|
||||
new_path="${new_path:+$new_path:}$dir"
|
||||
fi
|
||||
done
|
||||
|
||||
# Set PATH with current values if they don't already exist in the path
|
||||
if [[ -n "$new_path" ]]; then
|
||||
export PATH="$new_path:$PATH"
|
||||
fi
|
||||
|
||||
# Set MANPATH and INFOPATH if texlive directory exists
|
||||
if [ -d "/usr/local/texlive/2024/texmf-dist/doc/man" ]; then
|
||||
export MANPATH="/usr/local/texlive/2024/texmf-dist/doc/man:${MANPATH:-}"
|
||||
export INFOPATH="/usr/local/texlive/2024/texmf-dist/doc/info:${INFOPATH:-}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Run the function
|
||||
update_path
|
5
zsh/.config/zsh/pnpm.zsh
Normal file
5
zsh/.config/zsh/pnpm.zsh
Normal file
|
@ -0,0 +1,5 @@
|
|||
export PNPM_HOME="/home/$HOME/.local/share/pnpm"
|
||||
case ":$PATH:" in
|
||||
*":$PNPM_HOME:"*) ;;
|
||||
*) export PATH="$PNPM_HOME:$PATH" ;;
|
||||
esac
|
128
zsh/.config/zsh/rose-pine.sh
Normal file
128
zsh/.config/zsh/rose-pine.sh
Normal file
|
@ -0,0 +1,128 @@
|
|||
#{
|
||||
# Shell Color Setup Template
|
||||
# Chris Kempson (http://chriskempson.com)
|
||||
#}#!/bin/sh
|
||||
# Base16 Rosé Pine - Shell color setup script
|
||||
# Emilia Dunfelt <edun@dunfelt.se>
|
||||
|
||||
if [ "${TERM%%-*}" = 'linux' ]; then
|
||||
# This script doesn't support linux console (use 'vconsole' template instead)
|
||||
return 2>/dev/null || exit 0
|
||||
fi
|
||||
|
||||
color00="19/17/24" # Base 00 - Black
|
||||
color01="eb/6f/92" # Base 08 - Red
|
||||
color02="31/74/8f" # Base 0B - Green
|
||||
color03="eb/bc/ba" # Base 0A - Yellow
|
||||
color04="c4/a7/e7" # Base 0D - Blue
|
||||
color05="f6/c1/77" # Base 0E - Magenta
|
||||
color06="9c/cf/d8" # Base 0C - Cyan
|
||||
color07="e0/de/f4" # Base 05 - White
|
||||
color08="6e/6a/86" # Base 03 - Bright Black
|
||||
color09=$color01 # Base 08 - Bright Red
|
||||
color10=$color02 # Base 0B - Bright Green
|
||||
color11=$color03 # Base 0A - Bright Yellow
|
||||
color12=$color04 # Base 0D - Bright Blue
|
||||
color13=$color05 # Base 0E - Bright Magenta
|
||||
color14=$color06 # Base 0C - Bright Cyan
|
||||
color15="52/4f/67" # Base 07 - Bright White
|
||||
color16="f6/c1/77" # Base 09
|
||||
color17="52/4f/67" # Base 0F
|
||||
color18="1f/1d/2e" # Base 01
|
||||
color19="26/23/3a" # Base 02
|
||||
color20="90/8c/aa" # Base 04
|
||||
color21="e0/de/f4" # Base 06
|
||||
color_foreground="e0/de/f4" # Base 05
|
||||
color_background="19/17/24" # Base 00
|
||||
color_cursor="e0/de/f4" # Base 05
|
||||
|
||||
if [ -n "$TMUX" ]; then
|
||||
# tell tmux to pass the escape sequences through
|
||||
# (Source: http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324)
|
||||
printf_template="\033Ptmux;\033\033]4;%d;rgb:%s\007\033\\"
|
||||
printf_template_var="\033Ptmux;\033\033]%d;rgb:%s\007\033\\"
|
||||
printf_template_custom="\033Ptmux;\033\033]%s%s\007\033\\"
|
||||
elif [ "${TERM%%-*}" = "screen" ]; then
|
||||
# GNU screen (screen, screen-256color, screen-256color-bce)
|
||||
printf_template="\033P\033]4;%d;rgb:%s\007\033\\"
|
||||
printf_template_var="\033P\033]%d;rgb:%s\007\033\\"
|
||||
printf_template_custom="\033P\033]%s%s\007\033\\"
|
||||
elif [ -n "${-##*i*}" ]; then
|
||||
# non-interactive
|
||||
alias printf=/bin/false
|
||||
else
|
||||
printf_template="\033]4;%d;rgb:%s\033\\"
|
||||
printf_template_var="\033]%d;rgb:%s\033\\"
|
||||
printf_template_custom="\033]%s%s\033\\"
|
||||
fi
|
||||
|
||||
# 16 color space
|
||||
printf $printf_template 0 $color00
|
||||
printf $printf_template 1 $color01
|
||||
printf $printf_template 2 $color02
|
||||
printf $printf_template 3 $color03
|
||||
printf $printf_template 4 $color04
|
||||
printf $printf_template 5 $color05
|
||||
printf $printf_template 6 $color06
|
||||
printf $printf_template 7 $color07
|
||||
printf $printf_template 8 $color08
|
||||
printf $printf_template 9 $color09
|
||||
printf $printf_template 10 $color10
|
||||
printf $printf_template 11 $color11
|
||||
printf $printf_template 12 $color12
|
||||
printf $printf_template 13 $color13
|
||||
printf $printf_template 14 $color14
|
||||
printf $printf_template 15 $color15
|
||||
|
||||
# 256 color space
|
||||
printf $printf_template 16 $color16
|
||||
printf $printf_template 17 $color17
|
||||
printf $printf_template 18 $color18
|
||||
printf $printf_template 19 $color19
|
||||
printf $printf_template 20 $color20
|
||||
printf $printf_template 21 $color21
|
||||
|
||||
# foreground / background / cursor color
|
||||
if [ -n "$ITERM_SESSION_ID" ]; then
|
||||
# iTerm2 proprietary escape codes
|
||||
printf $printf_template_custom Pg e0def4 # forground
|
||||
printf $printf_template_custom Ph 191724 # background
|
||||
printf $printf_template_custom Pi e0def4 # bold color
|
||||
printf $printf_template_custom Pj 26233a # selection color
|
||||
printf $printf_template_custom Pk e0def4 # selected text color
|
||||
printf $printf_template_custom Pl e0def4 # cursor
|
||||
printf $printf_template_custom Pm 191724 # cursor text
|
||||
else
|
||||
printf $printf_template_var 10 $color_foreground
|
||||
printf $printf_template_var 11 $color_background
|
||||
printf $printf_template_custom 12 ";7" # cursor (reverse video)
|
||||
fi
|
||||
|
||||
# clean up
|
||||
unset printf_template
|
||||
unset printf_template_var
|
||||
unset color00
|
||||
unset color01
|
||||
unset color02
|
||||
unset color03
|
||||
unset color04
|
||||
unset color05
|
||||
unset color06
|
||||
unset color07
|
||||
unset color08
|
||||
unset color09
|
||||
unset color10
|
||||
unset color11
|
||||
unset color12
|
||||
unset color13
|
||||
unset color14
|
||||
unset color15
|
||||
unset color16
|
||||
unset color17
|
||||
unset color18
|
||||
unset color19
|
||||
unset color20
|
||||
unset color21
|
||||
unset color_foreground
|
||||
unset color_background
|
||||
unset color_cursor
|
41
zsh/.config/zsh/tmux.zsh
Normal file
41
zsh/.config/zsh/tmux.zsh
Normal file
|
@ -0,0 +1,41 @@
|
|||
if [ -z "$TMUX" ]; then
|
||||
# If we're in SSH
|
||||
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
|
||||
echo "Welcome via SSH..."
|
||||
# If we're in a TTY without X
|
||||
elif [ -z "$DISPLAY" ]; then
|
||||
# Optional X start code commented out
|
||||
# echo "Start X? ..."
|
||||
# startx
|
||||
# Regular terminal with no tmux
|
||||
else
|
||||
tmux_sessions=$(tmux ls 2>/dev/null)
|
||||
tmux_status=$?
|
||||
if [ $tmux_status -ne 0 ]; then
|
||||
echo "Press any key to cancel tmux autostart..."
|
||||
read -t 0.7 -n 1 -s -r
|
||||
if [ $? -ne 0 ]; then
|
||||
tmux new -s default
|
||||
fi
|
||||
else
|
||||
tmux attach -t default || tmux new -s default
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# tmux project launcher function
|
||||
function tmuxLauncher {
|
||||
selected_dir=$(/bin/fd --base-directory ~/Dev --search-path . -t d -d 2 | fzf)
|
||||
if [[ -n "$selected_dir" ]]; then
|
||||
if git rev-parse --git-dir &>/dev/null; then
|
||||
tmux rename-window "$selected_dir"
|
||||
cd "$HOME/Dev/$selected_dir"
|
||||
else
|
||||
tmux new-window -n "$selected_dir" -c "$HOME/Dev/$selected_dir"
|
||||
fi
|
||||
fi
|
||||
zle reset-prompt
|
||||
}
|
||||
|
||||
zle -N tmuxLauncher
|
||||
bindkey "^t" tmuxLauncher
|
BIN
zsh/.config/zsh/zsh_history_T14
Normal file
BIN
zsh/.config/zsh/zsh_history_T14
Normal file
Binary file not shown.
BIN
zsh/.config/zsh/zsh_history_main
Normal file
BIN
zsh/.config/zsh/zsh_history_main
Normal file
Binary file not shown.
4
zsh/.zshenv
Normal file
4
zsh/.zshenv
Normal file
|
@ -0,0 +1,4 @@
|
|||
source ~/.config/env
|
||||
|
||||
# If running from tty1 start sway
|
||||
[ "$(tty)" = "/dev/tty1" ] && exec dbus-run-session sway
|
Loading…
Add table
Add a link
Reference in a new issue