dev: automated commit - 2025-09-22 09:56:48
This commit is contained in:
parent
dbcbcf4077
commit
7bf9a172ac
37 changed files with 311 additions and 140 deletions
|
|
@ -23,7 +23,7 @@ function open {
|
|||
echo "Opens files using the system default application"
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
for i in "$@"; do
|
||||
if [[ ! -e "$i" ]]; then
|
||||
echo "Warning: '$i' does not exist" >&2
|
||||
|
|
@ -39,12 +39,12 @@ function fopen() {
|
|||
echo "Error: fd is not installed" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
if ! command -v fzf >/dev/null 2>&1; then
|
||||
echo "Error: fzf is not installed" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
local selected
|
||||
selected=$(fd "$@" | fzf --preview 'bat --color=always --style=numbers --line-range=:500 {}')
|
||||
[[ -n "$selected" ]] && setsid nohup xdg-open "$selected" >/dev/null 2>&1 &
|
||||
|
|
@ -57,7 +57,7 @@ function fopen() {
|
|||
# Smart package manager detection and execution
|
||||
function _package_manager {
|
||||
local pkg_manager=""
|
||||
|
||||
|
||||
# Detect package manager based on lock files
|
||||
if [[ -f bun.lockb ]]; then
|
||||
pkg_manager="bun"
|
||||
|
|
@ -95,7 +95,7 @@ function dc() {
|
|||
echo "If no message provided, uses timestamp-based message"
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
if ! git rev-parse --is-inside-work-tree &>/dev/null; then
|
||||
echo "Error: Not in a git repository" >&2
|
||||
return 1
|
||||
|
|
@ -139,7 +139,7 @@ function git-clean() {
|
|||
echo "Protects main, master, and develop branches"
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
if ! git rev-parse --is-inside-work-tree &>/dev/null; then
|
||||
echo "Error: Not in a git repository" >&2
|
||||
return 1
|
||||
|
|
@ -174,22 +174,13 @@ function git-clean() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Open Sublime Merge
|
||||
function sm {
|
||||
if [[ ! -f /opt/sublime_merge/sublime_merge ]]; then
|
||||
echo "Error: Sublime Merge not found at /opt/sublime_merge/sublime_merge" >&2
|
||||
return 1
|
||||
fi
|
||||
/opt/sublime_merge/sublime_merge "$@"
|
||||
}
|
||||
|
||||
# Quick access to Neovim config
|
||||
function vimrc {
|
||||
if [[ -z "$XDG_CONFIG_HOME" ]]; then
|
||||
echo "Error: XDG_CONFIG_HOME not set" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
local original_dir=$(pwd)
|
||||
cd "$XDG_CONFIG_HOME/nvim" || {
|
||||
echo "Error: Cannot access $XDG_CONFIG_HOME/nvim" >&2
|
||||
|
|
@ -199,13 +190,29 @@ function vimrc {
|
|||
cd "$original_dir"
|
||||
}
|
||||
|
||||
|
||||
function nixrc {
|
||||
if [[ -z "$XDG_CONFIG_HOME" ]]; then
|
||||
echo "Error: XDG_CONFIG_HOME not set" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local original_dir=$(pwd)
|
||||
cd "$XDG_CONFIG_HOME/nixos" || {
|
||||
echo "Error: Cannot access $XDG_CONFIG_HOME/nixos" >&2
|
||||
return 1
|
||||
}
|
||||
nvim
|
||||
cd "$original_dir"
|
||||
}
|
||||
|
||||
# Quick access to Zsh config
|
||||
function zshrc {
|
||||
if [[ -z "$XDG_CONFIG_HOME" ]]; then
|
||||
echo "Error: XDG_CONFIG_HOME not set" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
local original_dir=$(pwd)
|
||||
cd "$XDG_CONFIG_HOME/zsh" || {
|
||||
echo "Error: Cannot access $XDG_CONFIG_HOME/zsh" >&2
|
||||
|
|
@ -224,19 +231,19 @@ function expose() {
|
|||
echo "Example: expose 3000 # Exposes localhost:3000"
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "Error: Port number required" >&2
|
||||
echo "Usage: expose <port>" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
# Validate port number
|
||||
if ! [[ "$1" =~ ^[0-9]+$ ]] || [[ "$1" -lt 1 ]] || [[ "$1" -gt 65535 ]]; then
|
||||
echo "Error: Invalid port number. Must be between 1-65535" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
# Check if port is already in use
|
||||
if lsof -i ":$1" >/dev/null 2>&1; then
|
||||
echo "Warning: Port $1 is already in use" >&2
|
||||
|
|
@ -249,7 +256,7 @@ function expose() {
|
|||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
echo "Creating SSH tunnel for port $1..."
|
||||
ssh marianozunino@srv.us -R 1:localhost:"$1"
|
||||
}
|
||||
|
|
@ -263,19 +270,19 @@ function ppid {
|
|||
echo "Alias: pport"
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "Error: Port number required" >&2
|
||||
echo "Usage: ppid <port>" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
# Validate port number
|
||||
if ! [[ "$1" =~ ^[0-9]+$ ]] || [[ "$1" -lt 1 ]] || [[ "$1" -gt 65535 ]]; then
|
||||
echo "Error: Invalid port number. Must be between 1-65535" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
lsof -i ":$1"
|
||||
}
|
||||
|
||||
|
|
@ -295,7 +302,7 @@ function kf {
|
|||
echo "Example: kf prod my-service"
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "Error: Cluster name required" >&2
|
||||
echo "Usage: kf <cluster> [service-name]" >&2
|
||||
|
|
@ -314,7 +321,7 @@ function kf {
|
|||
echo "Error: kubefwd is not installed" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
echo "Starting kubefwd for cluster: $cluster"
|
||||
sudo -E kubefwd svc -n "${namespace}" -x "${cluster}" ${svc_filter}
|
||||
}
|
||||
|
|
@ -347,15 +354,15 @@ function wacom {
|
|||
echo "Supports both Wayland and X11 sessions"
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
if [[ "$XDG_SESSION_TYPE" = "wayland" ]]; then
|
||||
if ! command -v otd >/dev/null 2>&1; then
|
||||
echo "Error: opentabletdriver (otd) not found" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
systemctl --user enable opentabletdriver --now
|
||||
|
||||
|
||||
local config_file="$HOME/Sync/System/Configs/wacom/wacom.json"
|
||||
if [[ -f "$config_file" ]]; then
|
||||
otd loadsettings "$config_file"
|
||||
|
|
@ -368,14 +375,14 @@ function wacom {
|
|||
echo "Error: xsetwacom not found" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
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
|
||||
|
||||
xsetwacom --set "Wacom One by Wacom S Pen eraser" ResetArea
|
||||
xsetwacom --set "Wacom One by Wacom S Pen eraser" MapToOutput DisplayPort-0
|
||||
|
||||
|
||||
echo "Wacom configured for X11"
|
||||
fi
|
||||
}
|
||||
|
|
@ -389,13 +396,13 @@ function cat {
|
|||
echo "Automatically adjusts output for SSH sessions"
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
if ! command -v bat >/dev/null 2>&1; then
|
||||
echo "Warning: bat not found, falling back to system cat" >&2
|
||||
command cat "$@"
|
||||
return $?
|
||||
fi
|
||||
|
||||
|
||||
if [[ -n "$SSH_TTY" ]] || [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_CONNECTION" ]]; then
|
||||
bat --plain --paging=never "$@"
|
||||
else
|
||||
|
|
@ -413,7 +420,7 @@ function toggle_resolution() {
|
|||
echo " -m, --mirror Force mirror mode"
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
local mirror_mode=false
|
||||
|
||||
# Parse flags
|
||||
|
|
@ -434,7 +441,7 @@ function toggle_resolution() {
|
|||
echo "Error: swaymsg not found. This function requires Sway window manager" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
# Check if jq is available
|
||||
if ! command -v jq >/dev/null 2>&1; then
|
||||
echo "Error: jq not found. Required for JSON parsing" >&2
|
||||
|
|
@ -501,18 +508,18 @@ function cb {
|
|||
echo "Launch Code::Blocks with high contrast theme"
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
if [[ ! -f /usr/bin/codeblocks ]]; then
|
||||
echo "Error: Code::Blocks not found at /usr/bin/codeblocks" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
# Store original values
|
||||
local original_gtk_theme="$GTK_THEME"
|
||||
local original_gdk_theme="$GDK_THEME"
|
||||
local original_qt_style="$QT_STYLE_OVERRIDE"
|
||||
local original_xdg_desktop="$XDG_CURRENT_DESKTOP"
|
||||
|
||||
|
||||
# Set high contrast theme temporarily
|
||||
GTK_THEME=HighContrast \
|
||||
GDK_THEME=HighContrast \
|
||||
|
|
@ -521,7 +528,7 @@ function cb {
|
|||
GTK2_RC_FILES="" \
|
||||
GTK_RC_FILES="" \
|
||||
/usr/bin/codeblocks "$@"
|
||||
|
||||
|
||||
# Restore original values
|
||||
export GTK_THEME="$original_gtk_theme"
|
||||
export GDK_THEME="$original_gdk_theme"
|
||||
|
|
@ -539,13 +546,13 @@ function zrepo() {
|
|||
echo "Example: zrepo my-project"
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "Error: Repository name required" >&2
|
||||
echo "Usage: zrepo <repo-name>" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
# Validate repository name (basic check)
|
||||
if [[ ! "$1" =~ ^[a-zA-Z0-9_-]+$ ]]; then
|
||||
echo "Error: Repository name contains invalid characters" >&2
|
||||
|
|
@ -558,7 +565,7 @@ function zrepo() {
|
|||
local PATH_ON_SERVER="/var/git/$REPO.git"
|
||||
|
||||
echo "Creating repository '$REPO' on $SERVER..."
|
||||
|
||||
|
||||
ssh "$SERVER" "
|
||||
if [ -d $PATH_ON_SERVER ]; then
|
||||
echo 'Error: Repository '$REPO' already exists'
|
||||
|
|
@ -592,7 +599,7 @@ function _has {
|
|||
echo "Usage: _has <command>" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
whence "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
|
|
@ -604,12 +611,12 @@ function cdr {
|
|||
echo "Navigate to recently visited directories using fzf"
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
if ! command -v fzf >/dev/null 2>&1; then
|
||||
echo "Error: fzf is not installed" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
local dir
|
||||
dir=$(dirs -pl | awk '!x[$0]++' | fzf --height 40% --reverse)
|
||||
[[ -n "$dir" ]] && cd "$dir"
|
||||
|
|
@ -653,15 +660,15 @@ function font-switch() {
|
|||
echo "Example: font-switch jetbrains-mono"
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "Available fonts:"
|
||||
font-manager list
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
local font_name="$1"
|
||||
|
||||
|
||||
# Check if font exists
|
||||
if ! font-manager list | grep -q "$font_name"; then
|
||||
echo "Error: Font '$font_name' not found" >&2
|
||||
|
|
@ -669,17 +676,17 @@ function font-switch() {
|
|||
font-manager list >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
echo "Switching to $font_name fonts..."
|
||||
font-manager clean
|
||||
font-manager extract "$font_name"
|
||||
|
||||
|
||||
# Reload terminal if in kitty
|
||||
if [[ "$TERM" == "xterm-kitty" ]] && command -v kitty >/dev/null 2>&1; then
|
||||
echo "Reloading kitty configuration..."
|
||||
kitty @ set-colors --all ~/.config/kitty/kitty.conf
|
||||
fi
|
||||
|
||||
|
||||
echo "Font switch complete!"
|
||||
}
|
||||
|
||||
|
|
@ -692,24 +699,107 @@ function font-preview() {
|
|||
echo "Example: font-preview jetbrains-mono"
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "Error: Font name required" >&2
|
||||
echo "Usage: font-preview [font-name]" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
local font_name="$1"
|
||||
local preview_text="The quick brown fox jumps over the lazy dog
|
||||
ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
0123456789
|
||||
!@#$%^&*()_+-=[]{}|;':\",./<>?"
|
||||
|
||||
|
||||
echo "Previewing font: $font_name"
|
||||
echo "----------------------------------------"
|
||||
echo "$preview_text" | font-manager extract "$font_name" && echo "$preview_text"
|
||||
}
|
||||
|
||||
|
||||
yay() {
|
||||
case "$1" in
|
||||
# System update
|
||||
update|"-Syu")
|
||||
echo "Updating NixOS system..."
|
||||
nh os switch ~/.config/nixos --update
|
||||
;;
|
||||
|
||||
# Search packages
|
||||
search|"-Ss")
|
||||
[ -z "$2" ] && { echo "Usage: yay search <package>"; return 1; }
|
||||
echo "Searching for '$2'..."
|
||||
nix search nixpkgs "$2" 2>/dev/null || nix-env -qaP | grep -i "$2"
|
||||
;;
|
||||
|
||||
# Install package to user environment
|
||||
install|"-S")
|
||||
[ -z "$2" ] && { echo "Usage: yay install <package>"; return 1; }
|
||||
echo "Installing $2..."
|
||||
nix-env -iA nixpkgs.$2
|
||||
;;
|
||||
|
||||
# Remove package
|
||||
remove|"-R")
|
||||
[ -z "$2" ] && { echo "Usage: yay remove <package>"; return 1; }
|
||||
echo "Removing $2..."
|
||||
nix-env -e "$2"
|
||||
;;
|
||||
|
||||
# List installed packages
|
||||
list|"-Q")
|
||||
echo "Installed packages:"
|
||||
nix-env -q
|
||||
;;
|
||||
|
||||
# Clean up
|
||||
clean|"-Sc")
|
||||
echo "Cleaning nix store..."
|
||||
nix-collect-garbage
|
||||
sudo nix-collect-garbage -d
|
||||
;;
|
||||
|
||||
# Help
|
||||
help|"-h")
|
||||
bat -Pp << 'EOF'
|
||||
yay - Simple NixOS package manager wrapper
|
||||
|
||||
Commands:
|
||||
yay Rebuild system
|
||||
yay update Update system
|
||||
yay search <pkg> Search packages
|
||||
yay install <pkg> Install package (user)
|
||||
yay remove <pkg> Remove package
|
||||
yay list List installed packages
|
||||
yay clean Clean package cache
|
||||
yay help Show this help
|
||||
|
||||
Note: For system packages, edit ~/.config/nixos/configuration.nix
|
||||
EOF
|
||||
;;
|
||||
|
||||
# Default: rebuild system
|
||||
"")
|
||||
echo "Rebuilding NixOS system..."
|
||||
nh os switch ~/.config/nixos
|
||||
;;
|
||||
|
||||
# Try to install unknown commands
|
||||
*)
|
||||
if [[ ! "$1" =~ ^- ]]; then
|
||||
echo "Installing '$1'..."
|
||||
nix-env -iA nixpkgs.$1
|
||||
else
|
||||
echo "Unknown option: $1"
|
||||
echo "Run 'yay help' for available commands"
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function nas() {
|
||||
rclone mount --vfs-cache-mode writes --dir-cache-time 5s --no-check-certificate --allow-other nas: /home/mzunino/nas
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue