commit 714d050757eb3946ff7567d47dd2c526c1ac90ca Author: Mariano Z. Date: Mon Apr 21 12:07:24 2025 -0300 init diff --git a/.git-crypt/.gitattributes b/.git-crypt/.gitattributes new file mode 100644 index 0000000..665b10e --- /dev/null +++ b/.git-crypt/.gitattributes @@ -0,0 +1,4 @@ +# Do not edit this file. To specify the files to encrypt, create your own +# .gitattributes file in the directory where your files are. +* !filter !diff +*.gpg binary diff --git a/.git-crypt/keys/default/0/13D35660EC8E8AA03D4370A83FA93CB876C8FFAA.gpg b/.git-crypt/keys/default/0/13D35660EC8E8AA03D4370A83FA93CB876C8FFAA.gpg new file mode 100644 index 0000000..96d8fbb Binary files /dev/null and b/.git-crypt/keys/default/0/13D35660EC8E8AA03D4370A83FA93CB876C8FFAA.gpg differ diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..d54cf7f --- /dev/null +++ b/.gitattributes @@ -0,0 +1,11 @@ +# Sensitive files that should be encrypted with git-crypt +ssh/.ssh/config filter=git-crypt diff=git-crypt +gnupg/.gnupg/* filter=git-crypt diff=git-crypt +npm/.config/npm/npmrc filter=git-crypt diff=git-crypt +zsh/.config/zsh/zsh_history* filter=git-crypt diff=git-crypt +config/.config/sdm-ui.yaml filter=git-crypt diff=git-crypt +config/.config/ngrok/ngrok.yml filter=git-crypt diff=git-crypt + +# Add any new paths for sensitive files in your new modules +# For example, if you have API tokens in new locations: +# mise/.config/mise/config.toml filter=git-crypt diff=git-crypt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8e5f5e5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +bin/.bin/code +bin/.bin/sdm-ui +bin/.bin/goq +bin/.bin/rop + +local-bin/.local/bin/mise diff --git a/.stow-global-ignore b/.stow-global-ignore new file mode 100644 index 0000000..4301a1e --- /dev/null +++ b/.stow-global-ignore @@ -0,0 +1,21 @@ +# Comments and blank lines are allowed. + +RCS +.+,v + +CVS +\.\#.+ # CVS conflict files / emacs lock files +\.cvsignore + +\.git +\.gitignore +\.gitattributes + +^/README.* +^/LICENSE.* +^/COPYING + +# Custom ignores for dotfiles +\.DS_Store +README.md +LICENSE diff --git a/.stowrc b/.stowrc new file mode 100644 index 0000000..827a1d9 --- /dev/null +++ b/.stowrc @@ -0,0 +1,4 @@ +--target=${HOME} +--dir=${HOME}/dotfiles +--verbose +--no-folding diff --git a/README.md b/README.md new file mode 100644 index 0000000..749f65b --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# Dotfiles + +Personal dotfiles for my Linux system running Sway (Wayland). + +## Overview + +- **Window Management**: Sway, Waybar, Swayidle +- **Terminals**: Kitty, WezTerm +- **Development**: Neovim, Git, Tmux, npm, mise +- **Shell**: Zsh with custom functions, aliases, keymaps +- **Launchers**: Rofi, Fuzzel + +## Requirements + +- stow +- git-crypt (for encrypted files) + +## Installation + +```bash +# Clone repository +git clone https://github.com/yourusername/dotfiles.git ~/.dotfiles +cd ~/.dotfiles + +# Decrypt sensitive files (if you have access) +git-crypt unlock /path/to/key + +# Install everything +stow */ + +# Or install individual modules +stow zsh +stow nvim +stow sway +``` + +## License + +MIT diff --git a/applications/.local/share/applications/custom/DBeaver.desktop b/applications/.local/share/applications/custom/DBeaver.desktop new file mode 100755 index 0000000..535f312 --- /dev/null +++ b/applications/.local/share/applications/custom/DBeaver.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Terminal=false +Name=DBeaver +GenericName=SQL Database Client +Comment=Universal Database Manager and SQL Client. +Exec=bash -c "GDK_BACKEND=x11 GTK_THEME=Raleigh /usr/bin/dbeaver" +Categories=IDE;Development +WM_CLASS=DBeaver +StartupWMClass=DBeaver +StartupNotify=true +Icon=/usr/share/pixmaps/dbeaver.png diff --git a/applications/.local/share/applications/custom/Leapp.desktop b/applications/.local/share/applications/custom/Leapp.desktop new file mode 100755 index 0000000..a2850c2 --- /dev/null +++ b/applications/.local/share/applications/custom/Leapp.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Terminal=false +Name=Leapp +GenericName=AWS Profile Manager +Exec=/home/forbi/.bin/leapp.sh +Categories=IDE;Development +StartupWMClass=Leapp +StartupNotify=true +Icon=/home/forbi/Downloads/leapp.svg diff --git a/applications/.local/share/applications/custom/Lens.desktop b/applications/.local/share/applications/custom/Lens.desktop new file mode 100644 index 0000000..6701f11 --- /dev/null +++ b/applications/.local/share/applications/custom/Lens.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Type=Application +Name=Lens +GenericName=Kubernetes IDE +Comment=The Kubernetes IDE +Icon=/home/forbi/.local/share/applications/custom/lens.png +Exec=/home/forbi/.bin/openlens %U +Categories=System; +StartupNotify=true +StartupWMClass=Lens +MimeType=x-scheme-handler/lens; diff --git a/applications/.local/share/applications/custom/NoSQL.desktop b/applications/.local/share/applications/custom/NoSQL.desktop new file mode 100755 index 0000000..24db2ec --- /dev/null +++ b/applications/.local/share/applications/custom/NoSQL.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=NoSQL Booster +Exec=/home/forbi/.bin/nosql.sh +Icon=~/.local/share/applications/custom/mongo.png +Version=1.0 +Type=Application +Terminal=0 + diff --git a/applications/.local/share/applications/custom/Recorder.desktop b/applications/.local/share/applications/custom/Recorder.desktop new file mode 100755 index 0000000..906b2c4 --- /dev/null +++ b/applications/.local/share/applications/custom/Recorder.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Terminal=false +Name=Screen Recorder +GenericName=Screen Recorder +Exec= /home/forbi/.bin/wlrecord.sh -s +Categories=Utility;Application; +StartupWMClass=Screen Recorder +StartupNotify=true +Icon=/usr/share/icons/ePapirus/24x24/actions/kdenlive-hide-video.svg diff --git a/applications/.local/share/applications/custom/Redis.desktop b/applications/.local/share/applications/custom/Redis.desktop new file mode 100755 index 0000000..56298d1 --- /dev/null +++ b/applications/.local/share/applications/custom/Redis.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Terminal=false +Name=Redis +GenericName=Redis Viewer +Exec=/home/forbi/.bin/redis.sh +Categories=IDE;Development +StartupWMClass=Redis +StartupNotify=true +Icon=/home/forbi/.local/share/applications/custom/redis.png diff --git a/applications/.local/share/applications/custom/Syncthing.desktop b/applications/.local/share/applications/custom/Syncthing.desktop new file mode 100755 index 0000000..38b45a6 --- /dev/null +++ b/applications/.local/share/applications/custom/Syncthing.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Terminal=false +Name=Syncthing UI +GenericName=Syncthing UI +Exec=xdg-open http://localhost:8384 +Categories=Network;FileTransfer; +StartupNotify=true +Icon=syncthing diff --git a/applications/.local/share/applications/custom/lens.jpg b/applications/.local/share/applications/custom/lens.jpg new file mode 100644 index 0000000..ef16534 Binary files /dev/null and b/applications/.local/share/applications/custom/lens.jpg differ diff --git a/applications/.local/share/applications/custom/lens.png b/applications/.local/share/applications/custom/lens.png new file mode 100644 index 0000000..11ede9d Binary files /dev/null and b/applications/.local/share/applications/custom/lens.png differ diff --git a/applications/.local/share/applications/custom/mongo.png b/applications/.local/share/applications/custom/mongo.png new file mode 100644 index 0000000..796681b Binary files /dev/null and b/applications/.local/share/applications/custom/mongo.png differ diff --git a/applications/.local/share/applications/custom/nvim.desktop b/applications/.local/share/applications/custom/nvim.desktop new file mode 100644 index 0000000..5493731 --- /dev/null +++ b/applications/.local/share/applications/custom/nvim.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Type=Application +Name=Kitty+Neovim +Comment=Open Neovim in Kitty terminal +Exec=kitty -e nvim %F +Icon=nvim +Terminal=false +Categories=Utility;TextEditor; +MimeType=text/plain; diff --git a/applications/.local/share/applications/custom/redis.png b/applications/.local/share/applications/custom/redis.png new file mode 100644 index 0000000..021c412 Binary files /dev/null and b/applications/.local/share/applications/custom/redis.png differ diff --git a/applications/.local/share/applications/custom/sublime_merge.desktop b/applications/.local/share/applications/custom/sublime_merge.desktop new file mode 100644 index 0000000..c03c8e1 --- /dev/null +++ b/applications/.local/share/applications/custom/sublime_merge.desktop @@ -0,0 +1,18 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Name=Sublime Merge +GenericName=Git Client +Comment=Sublime Merge is a Git client, from the makers of Sublime Text +Exec=/home/forbi/.bin/sm.sh %F +Terminal=false +MimeType=text/plain; +Icon=sublime-merge +Categories=Development; +StartupNotify=true +Actions=new-window; + +[Desktop Action new-window] +Name=New Window +Exec=/home/forbi/.bin/sm --launch-or-new-window +OnlyShowIn=Unity; diff --git a/bin/.bin/base16-rose-pine-scheme.sh b/bin/.bin/base16-rose-pine-scheme.sh new file mode 100755 index 0000000..9d77c51 --- /dev/null +++ b/bin/.bin/base16-rose-pine-scheme.sh @@ -0,0 +1,126 @@ +#!/bin/sh +# base16-shell (https://github.com/chriskempson/base16-shell) +# Base16 Shell template by Chris Kempson (http://chriskempson.com) +# RosΓ© Pine Dawn scheme by Emilia Dunfelt <sayhi@dunfelt.se> + +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="90/8c/aa" # 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="eb/6f/92" # Base 0F +color18="1f/1d/2e" # Base 01 +color19="26/23/3a" # Base 02 +color20="6e/6a/86" # Base 03 +color21="52/4f/67" # Base 04 +color_foreground="e0/de/f4" # Base 05 +color_background="19/17/24" # Base 00 + +if [ -n "$TMUX" ]; then + # Tell tmux to pass the escape sequences through + # (Source: http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324) + put_template() { printf '\033Ptmux;\033\033]4;%d;rgb:%s\033\033\\\033\\' $@; } + put_template_var() { printf '\033Ptmux;\033\033]%d;rgb:%s\033\033\\\033\\' $@; } + put_template_custom() { printf '\033Ptmux;\033\033]%s%s\033\033\\\033\\' $@; } +elif [ "${TERM%%[-.]*}" = "screen" ]; then + # GNU screen (screen, screen-256color, screen-256color-bce) + put_template() { printf '\033P\033]4;%d;rgb:%s\007\033\\' $@; } + put_template_var() { printf '\033P\033]%d;rgb:%s\007\033\\' $@; } + put_template_custom() { printf '\033P\033]%s%s\007\033\\' $@; } +elif [ "${TERM%%-*}" = "linux" ]; then + put_template() { [ $1 -lt 16 ] && printf "\e]P%x%s" $1 $(echo $2 | sed 's/\///g'); } + put_template_var() { true; } + put_template_custom() { true; } +else + put_template() { printf '\033]4;%d;rgb:%s\033\\' $@; } + put_template_var() { printf '\033]%d;rgb:%s\033\\' $@; } + put_template_custom() { printf '\033]%s%s\033\\' $@; } +fi + +# 16 color space +put_template 0 $color00 +put_template 1 $color01 +put_template 2 $color02 +put_template 3 $color03 +put_template 4 $color04 +put_template 5 $color05 +put_template 6 $color06 +put_template 7 $color07 +put_template 8 $color08 +put_template 9 $color09 +put_template 10 $color10 +put_template 11 $color11 +put_template 12 $color12 +put_template 13 $color13 +put_template 14 $color14 +put_template 15 $color15 + +# 256 color space +put_template 16 $color16 +put_template 17 $color17 +put_template 18 $color18 +put_template 19 $color19 +put_template 20 $color20 +put_template 21 $color21 + +# foreground / background / cursor color +if [ -n "$ITERM_SESSION_ID" ]; then + # iTerm2 proprietary escape codes + put_template_custom Pg 575279 # foreground + put_template_custom Ph faf4ed # background + put_template_custom Pi 575279 # bold color + put_template_custom Pj f2e9de # selection color + put_template_custom Pk 575279 # selected text color + put_template_custom Pl 575279 # cursor + put_template_custom Pm faf4ed # cursor text +else + put_template_var 10 $color_foreground + if [ "$BASE16_SHELL_SET_BACKGROUND" != false ]; then + put_template_var 11 $color_background + if [ "${TERM%%-*}" = "rxvt" ]; then + put_template_var 708 $color_background # internal border (rxvt) + fi + fi + put_template_custom 12 ";7" # cursor (reverse video) +fi + +# clean up +unset -f put_template +unset -f put_template_var +unset -f put_template_custom +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 diff --git a/bin/.bin/code.sh b/bin/.bin/code.sh new file mode 100755 index 0000000..efcd8a8 --- /dev/null +++ b/bin/.bin/code.sh @@ -0,0 +1,15 @@ +#!/bin/bash +MODULE_URL="mzunino.com.uy/go/code" +BINARY_NAME="code" + +TARGET_DIR="$HOME/.bin" +CODE_PATH="$TARGET_DIR/$BINARY_NAME" +if [ ! -x "$CODE_PATH" ]; then + notify-send "Installing $BINARY_NAME" "Installing from $MODULE_URL..." + GO111MODULE=on GOBIN="$TARGET_DIR" go install "$MODULE_URL@latest" || { + notify-send -u critical "Installation Failed" "Failed to install $BINARY_NAME from $MODULE_URL" + exit 1 + } + notify-send "Installation Complete" "$BINARY_NAME has been installed successfully" +fi +exec "$CODE_PATH" "$@" diff --git a/bin/.bin/fix-git.sh b/bin/.bin/fix-git.sh new file mode 100755 index 0000000..d273ef4 --- /dev/null +++ b/bin/.bin/fix-git.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +OLD_URL=$(git remote get-url origin) +if [[ $OLD_URL == "https://github.com"* ]]; then + # Modified sed pattern to better handle GitHub URLs + USER_REPO=$(echo $OLD_URL | sed -n 's|https://github.com/\([^/]*/[^/]*\)|\1|p') + if [ -z "$USER_REPO" ]; then + echo "Error: Could not extract user/repo from URL: $OLD_URL" + exit 1 + fi + + # Remove any trailing .git if present and add it back consistently + USER_REPO=$(echo $USER_REPO | sed 's/\.git$//') + NEW_URL="git@github.com:${USER_REPO}.git" + + echo "Old URL: $OLD_URL" + echo "New URL: $NEW_URL" + + # Update the remote URL to use SSH + git remote set-url origin "$NEW_URL" + + # Verify the change + CURRENT_URL=$(git remote get-url origin) + if [ "$CURRENT_URL" = "$NEW_URL" ]; then + echo "Successfully updated remote URL to use SSH." + else + echo "Error: Failed to update remote URL." + exit 1 + fi +else + echo "Remote URL is already using SSH or a different protocol: $OLD_URL" +fi diff --git a/bin/.bin/fuzzel.lua b/bin/.bin/fuzzel.lua new file mode 100644 index 0000000..f64bc6f --- /dev/null +++ b/bin/.bin/fuzzel.lua @@ -0,0 +1,53 @@ +return { + selector_cmd = function() + return { + command = "rofi", + args = { "-dmenu", "-p", "Project: " }, + } + end, + editor_cmd = function(path, class) + local dirName = path:match("([^/]+)$") + -- Sanitize dirName for tmux session name (remove special chars) + local tmuxSession = dirName:gsub("[^a-zA-Z0-9_]", "_") + + local tmuxCmd = string.format( + [[ tmux has-session -t %s 2>/dev/null && tmux attach -t %s || tmux new -c %s -s %s 'nvim %s' \; split-window -h -c %s ]], + tmuxSession, + tmuxSession, + path, + tmuxSession, + path, + path + ) + return { + command = "kitty", + args = { + "-d", + path, + "-T", + class, + "--class", + class, + "sh", + "-c", + tmuxCmd, + }, + } + end, + format_project_title = function(path) + -- Extract project name for better display + -- local projectName = path:match("([^/]+)$") or path + return "πŸ“˜ " .. path + end, + + extract_path_from_title = function(title) + -- Return back the path: πŸ“˜ work/project_1 -> work/project_1 + return title:gsub("^πŸ“˜%s*", ""):gsub("\n$", "") + end, + + -- Add error handling function + handle_error = function(err) + io.stderr:write("Error: " .. tostring(err) .. "\n") + return false + end, +} diff --git a/bin/.bin/goq.sh b/bin/.bin/goq.sh new file mode 100755 index 0000000..f875e71 --- /dev/null +++ b/bin/.bin/goq.sh @@ -0,0 +1,15 @@ +#!/bin/bash +MODULE_URL="github.com/marianozunino/goq" +BINARY_NAME="goq" + +TARGET_DIR="$HOME/.bin" +CODE_PATH="$TARGET_DIR/$BINARY_NAME" +if [ ! -x "$CODE_PATH" ]; then + notify-send "Installing $BINARY_NAME" "Installing from $MODULE_URL..." + GO111MODULE=on GOBIN="$TARGET_DIR" go install "$MODULE_URL@latest" || { + notify-send -u critical "Installation Failed" "Failed to install $BINARY_NAME from $MODULE_URL" + exit 1 + } + notify-send "Installation Complete" "$BINARY_NAME has been installed successfully" +fi +exec "$CODE_PATH" "$@" diff --git a/bin/.bin/leapp.sh b/bin/.bin/leapp.sh new file mode 100755 index 0000000..806ef09 --- /dev/null +++ b/bin/.bin/leapp.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +bin=~/.bin/leapp +latest_version_url="https://api.github.com/repos/noovolari/leapp/releases/latest" + +# Function to compare version numbers +function version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; } + +# If leapp binary is not found or if there is a newer version, download it +if [ ! -f $bin ] || version_gt "$(curl -s $latest_version_url | grep -oP '"tag_name": "\K(.*)(?=")')" "$(basename $bin | grep -oP '\d+\.\d+\.\d+')"; then + notify-send -u normal "⏬ Leapp" "Checking for updates..." + url="https://asset.noovolari.com/latest/Leapp-appImage.zip" + wget -q -O /tmp/leapp.AppImage "$url" + unzip /tmp/leapp.AppImage -d /tmp + mv /tmp/release/Leapp* $bin + chmod +x $bin +fi + +# Execute leapp +$bin -f -i $1 -o $2 diff --git a/bin/.bin/lock.sh b/bin/.bin/lock.sh new file mode 100755 index 0000000..157db44 --- /dev/null +++ b/bin/.bin/lock.sh @@ -0,0 +1,25 @@ +#!/bin/bash +swaylock -f \ + --screenshots \ + --clock \ + --indicator \ + --indicator-radius 150 \ + --indicator-thickness 7 \ + --font-size 24 \ + --effect-blur 7x5 \ + --effect-vignette 0.5:0.5 \ + --ring-color 9ccfd8 \ + --ring-ver-color f6c177 \ + --ring-wrong-color eb6f92 \ + --key-hl-color eb6f92 \ + --line-color 00000000 \ + --inside-color 191724aa \ + --inside-ver-color 191724aa \ + --inside-wrong-color 191724aa \ + --separator-color 00000000 \ + --text-color e0def4 \ + --text-ver-color e0def4 \ + --text-wrong-color e0def4 \ + --text-caps-lock-color f6c177 \ + --grace 2 \ + --fade-in 0.2 diff --git a/bin/.bin/nosql.sh b/bin/.bin/nosql.sh new file mode 100755 index 0000000..f4cdd16 --- /dev/null +++ b/bin/.bin/nosql.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +bin=$HOME/.bin/nosql + +# if nosql binary is not found, download it +if [ ! -f $bin ]; then + echo "Downloading NoSql binary..." + url="https://s3.nosqlbooster.com/download/releasesv7/nosqlbooster4mongo-7.1.17.AppImage" + wget -q -O $bin $url + chmod +x $bin +fi + +# execute leapp +$bin diff --git a/bin/.bin/obsidian-launcher b/bin/.bin/obsidian-launcher new file mode 100755 index 0000000..d760832 --- /dev/null +++ b/bin/.bin/obsidian-launcher @@ -0,0 +1,6 @@ +#!/usr/bin/env sh +swaymsg '[class="obsidian"]' focus && exit + +if [ $? -ne 0 ]; then + obsidian && swaymsg '[class="obsidian"]' focus >/dev/null 2>&1 +fi diff --git a/bin/.bin/openlens.sh b/bin/.bin/openlens.sh new file mode 100755 index 0000000..f445518 --- /dev/null +++ b/bin/.bin/openlens.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +bin=~/.bin/openlens + +repo=MuhammedKalkan/OpenLens +# if redis binary is not found, download it +if [ ! -f $bin ]; then + echo "Downloading openlens binary..." + filename=$(curl -s https://api.github.com/repos/$repo/releases/latest | jq -r '.assets[].name' | grep "x86_64.AppImage$") + fileurl=$(curl -s https://api.github.com/repos/$repo/releases/latest | jq -r --arg filename $filename '.assets[] | select(.name == $filename) | .browser_download_url') + wget -q -O $bin $fileurl + chmod +x $bin +fi + +# execute leapp +$bin -f -i $1 -o $2 diff --git a/bin/.bin/randwall b/bin/.bin/randwall new file mode 100755 index 0000000..e50779e --- /dev/null +++ b/bin/.bin/randwall @@ -0,0 +1,35 @@ +#!/bin/bash + +# Kill any existing swaybg or feh instances +pkill swaybg +pkill feh + +# Function to set wallpaper using swaybg on Sway +set_wallpaper_sway() { + swaymsg -t get_outputs -r | jq -r ".[].name" | parallel 'swaybg -o {} -i $(find ~/Pictures/* -type f | shuf -n 1) &' +} + +# Function to set wallpaper using swaybg on Hyprland +set_wallpaper_hyprland() { + hyprctl monitors -j | jq -r ".[].name" | parallel 'swaybg -o {} -i $(find ~/Pictures/* -type f | shuf -n 1) &' +} + +# Function to set wallpaper using feh on i3 +set_wallpaper_i3() { + # Count number of connected monitors + monitor_count=$(xrandr --query | grep " connected" | wc -l) + + # Get random wallpapers equal to monitor count + readarray -t wallpapers < <(find ~/Pictures/* -type f | shuf -n "$monitor_count") + + # Construct the feh command with multiple --bg-fill arguments + cmd="feh" + for wallpaper in "${wallpapers[@]}"; do + cmd+=" --bg-fill '$wallpaper'" + done + + # Execute the command + eval "$cmd" +} + +set_wallpaper_sway diff --git a/bin/.bin/redis.sh b/bin/.bin/redis.sh new file mode 100755 index 0000000..3c5274e --- /dev/null +++ b/bin/.bin/redis.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# Define paths +bin_dir=~/.bin +bin_file="${bin_dir}/redis" + +# Create directory if it doesn't exist +mkdir -p "${bin_dir}" + +# Set current working directory +cd "${bin_dir}" + +if [ ! -f "${bin_file}" ]; then + notify-send -u normal "⏬ Redis Desktop Manager" "Downloading..." + + # Get latest release info and parse with proper JSON handling + release_info=$(curl -s https://api.github.com/repos/qishibo/AnotherRedisDesktopManager/releases/latest) + + # Determine system architecture + arch=$(uname -m) + if [ "${arch}" = "x86_64" ]; then + arch_pattern="x86_64" + elif [ "${arch}" = "aarch64" ]; then + arch_pattern="arm64" + else + echo "Unsupported architecture: ${arch}" + exit 1 + fi + + # Find appropriate AppImage for this architecture + filename=$(echo "${release_info}" | jq -r ".assets[].name" | grep "AppImage" | grep "${arch_pattern}") + echo "Selected filename: ${filename}" + + # Get download URL + fileurl=$(echo "${release_info}" | jq -r --arg filename "${filename}" '.assets[] | select(.name == $filename) | .browser_download_url') + echo "Download URL: ${fileurl}" + + # Download and make executable + if [ -n "${fileurl}" ] && [ "${fileurl}" != "null" ]; then + wget -q --show-progress -O "${bin_file}" "${fileurl}" + chmod +x "${bin_file}" + echo "Successfully downloaded Redis Desktop Manager" + else + echo "Failed to find download URL for architecture: ${arch}" + exit 1 + fi +fi + +# Execute with parameters if provided +"${bin_file}" -f ${1:+"-i"} ${1:+"$1"} ${2:+"-o"} ${2:+"$2"} diff --git a/bin/.bin/rop.sh b/bin/.bin/rop.sh new file mode 100755 index 0000000..1c7a763 --- /dev/null +++ b/bin/.bin/rop.sh @@ -0,0 +1,15 @@ +#!/bin/bash +GO_PACKAGE="github.com/marianozunino/rop" +BINARY_NAME="rop" + +TARGET_DIR="$HOME/.bin" +CODE_PATH="$TARGET_DIR/$BINARY_NAME" +if [ ! -x "$CODE_PATH" ]; then + notify-send "Installing $BINARY_NAME" "Installing from $MODULE_URL..." + GO111MODULE=on GOBIN="$TARGET_DIR" go install "$MODULE_URL@latest" || { + notify-send -u critical "Installation Failed" "Failed to install $BINARY_NAME from $MODULE_URL" + exit 1 + } + notify-send "Installation Complete" "$BINARY_NAME has been installed successfully" +fi +exec "$CODE_PATH" "$@" diff --git a/bin/.bin/screenshot-upload b/bin/.bin/screenshot-upload new file mode 100755 index 0000000..4615333 --- /dev/null +++ b/bin/.bin/screenshot-upload @@ -0,0 +1,7 @@ +#!/bin/bash +file=/tmp/$(date "+%Y%m%d-%H%M%S")_screenshot.png + +grim -g "$(slurp)" "$file" && + satty --filename "$file" --fullscreen && + yad --title="Upload?" --text="Upload image?" --image="dialog-question" --default-cancel && + curl -F "file=@$file" https://drop.mz.uy | xargs xdg-open diff --git a/bin/.bin/sdm-ui.sh b/bin/.bin/sdm-ui.sh new file mode 100755 index 0000000..7842e8c --- /dev/null +++ b/bin/.bin/sdm-ui.sh @@ -0,0 +1,15 @@ +#!/bin/bash +MODULE_URL="github.com/marianozunino/sdm-ui" +BINARY_NAME="sdm-ui" + +TARGET_DIR="$HOME/.bin" +CODE_PATH="$TARGET_DIR/$BINARY_NAME" +if [ ! -x "$CODE_PATH" ]; then + notify-send "Installing $BINARY_NAME" "Installing from $MODULE_URL..." + GO111MODULE=on GOBIN="$TARGET_DIR" go install "$MODULE_URL@latest" || { + notify-send -u critical "Installation Failed" "Failed to install $BINARY_NAME from $MODULE_URL" + exit 1 + } + notify-send "Installation Complete" "$BINARY_NAME has been installed successfully" +fi +exec "$CODE_PATH" "$@" diff --git a/bin/.bin/sm.sh b/bin/.bin/sm.sh new file mode 100755 index 0000000..f3f575d --- /dev/null +++ b/bin/.bin/sm.sh @@ -0,0 +1,23 @@ +#!/bin/bash +URL=$(curl https://www.sublimemerge.com/download_thanks?target=x64-tar#direct-downloads | grep -oP 'https://download.sublimetext.com/sublime_merge_build_\d+_x64.tar.xz' | head -n 1) +VERSION=$(echo $URL | grep -oP '\d+' | head -n 1) +FILENAME=sublime_merge_build_"$VERSION"_x64.tar.xz +bin=~/.bin/sm + +# set current working directory to ~/.bin +cd ~/.bin + +# if FILENAME exists, then exit +if [ ! -f $FILENAME ]; then + notify-send -u normal "⏬ Sublime Merge" "Updating to version $VERSION" + # wget only if file does not exist + wget -nc $URL + tar -xvf $FILENAME +fi + +if [ ! -f $bin ]; then + ln -fs $PWD/sublime_merge/sublime_merge $bin +fi + +# run sm +$bin diff --git a/bin/.bin/vmrss b/bin/.bin/vmrss new file mode 100755 index 0000000..24a0a4f --- /dev/null +++ b/bin/.bin/vmrss @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +if [ $# -eq 0 ]; then + echo "Usage: $0 " + exit 1 +fi + +function print_vmrss() { + declare -a arr + arr=("$1" 0) + total=0 + + while [ ${#arr[@]} -gt 0 ]; do + + # remove last element + space=${arr[${#arr[@]}-1]} + unset arr[${#arr[@]}-1] + pid=${arr[${#arr[@]}-1]} + unset arr[${#arr[@]}-1] + + [ -d "/proc/$pid" ] || continue + + GREP_OPTS=${GREP_OPTS:-" + --color=auto + --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox} + "} + mem=$(grep $GREP_OPTS VmRSS /proc/$pid/status \ + | grep $GREP_OPTS -o '[0-9]\+' \ + | awk '{print $1/1024}') + #Add decimals to total + total=$(echo $mem+$total | bc) + + # name of process + name=$(ps -p $pid -o comm=) + + printf "%${space}s%s($pid): $mem MB\n" '' "$name" + + # get children + children=$(pgrep -P $pid) + + # add children to array + for child in $children; do + arr+=("$child" $((space+2))) + done + done + printf "Total: $total MB\n" +} + +# check VMRSS_MONITOR = 1 +if [ ! -z "$VMRSS_MONITOR" ]; then + while true; do + if ps -p $1 > /dev/null + then + print_vmrss $1 + sleep 0.5 + else + break + fi + done + print_vmrss $1 +else + print_vmrss $1 +fi diff --git a/bin/.bin/waybar.sh b/bin/.bin/waybar.sh new file mode 100755 index 0000000..1cb365b --- /dev/null +++ b/bin/.bin/waybar.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +CONFIG_FILES="$HOME/.config/waybar/config.jsonc $HOME/.config/waybar/style.css" + +trap "killall waybar" EXIT + +while true; do + waybar & + inotifywait -e create,modify $CONFIG_FILES + killall waybar +done diff --git a/bin/.bin/wlrecord.sh b/bin/.bin/wlrecord.sh new file mode 100755 index 0000000..c399c45 Binary files /dev/null and b/bin/.bin/wlrecord.sh differ diff --git a/config/.config/env b/config/.config/env new file mode 100755 index 0000000..93bc524 --- /dev/null +++ b/config/.config/env @@ -0,0 +1,49 @@ +#!/bin/sh +export EDITOR="nvim" +export TERMINAL="kitty" +export LANG=en_US.UTF-8 +export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-~/.config} +export XDG_CACHE_HOME=${XDG_CACHE_HOME:-~/.cache} +export XDG_DATA_HOME=${XDG_DATA_HOME:-~/.local/share} +export XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-~/.xdg} +export XDG_STATE_HOME=${XDG_STATE_HOME:-~/.local/state} +export ZDOTDIR=${ZDOTDIR:-$XDG_CONFIG_HOME/zsh} +export WAKATIME_HOME=$XDG_CONFIG_HOME/wakatime +export ZSH_WAKATIME_BIN=$XDG_CONFIG_HOME/wakatime/.wakatime/wakatime-cli +export W3M_DIR=$XDG_DATA_HOME/w3m +export RANDFILE=$XDG_CACHE_HOME/.rnd +export SOLARGRAPH_CACHE=$XDG_CACHE_HOME/solargraph +export NPM_CONFIG_USERCONFIG=$XDG_CONFIG_HOME/npm/npmrc +export NODE_REPL_HISTORY=$XDG_DATA_HOME/node_repl_history +export GRADLE_USER_HOME=$XDG_DATA_HOME/gradle +export GOPATH=$XDG_DATA_HOME/go +export DOCKER_CONFIG=$XDG_CONFIG_HOME/docker +export CARGO_HOME=$XDG_DATA_HOME/cargo +# bash history +export HISTFILE=${XDG_STATE_HOME}/bash/history +export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc-2.0" +export WGETRC="$XDG_CONFIG_HOME/wgetrc" +export JAVA_HOME="/usr/lib/jvm/default" +export BROWSER=zen-browser +unset SSH_AGENT_PID +if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then + export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" +fi +export GNUHOME="$XDG_DATA_HOME/gnupg" +export GPG_TTY=$(tty) +gpg-connect-agent updatestartuptty /bye >/dev/null + +# Wayland/Sway specific environment variables +export MOZ_ENABLE_WAYLAND=1 +export QT_QPA_PLATFORM=wayland-egl +export QT_WAYLAND_DISABLE_WINDOWDECORATION=1 +export QT_QPA_PLATFORMTHEME=qt5ct +export QT_STYLE_OVERRIDE=kvantum +export CLUTTER_BACKEND=wayland +export GDK_BACKEND=wayland +export ECORE_EVAS_ENGINE=wayland_egl +export ELM_ENGINE=wayland_wgl +export SDL_VIDEODRIVER=wayland +export _JAVA_AWT_WM_NONREPARENTING=1 +export XDG_CURRENT_DESKTOP=sway +export XDG_SESSION_TYPE=wayland diff --git a/config/.config/ngrok/ngrok.yml b/config/.config/ngrok/ngrok.yml new file mode 100644 index 0000000..2788e51 --- /dev/null +++ b/config/.config/ngrok/ngrok.yml @@ -0,0 +1,5 @@ +version: "2" +authtoken: 2VfBGWRQlvjn98qZWh5FN2LIvP6_6dnw93WaHALJPfTCnuXEw +region: us +console_ui_color: transparent + diff --git a/config/.config/sdm-ui.yaml b/config/.config/sdm-ui.yaml new file mode 100644 index 0000000..7a7961b --- /dev/null +++ b/config/.config/sdm-ui.yaml @@ -0,0 +1,14 @@ +email: mariano.zunino@partech.com +verbose: true +blacklistPatterns: + - ".*feature.*" + - "nessus" + - ".*rmq-tcp" + - ".*readonly.*" + - ".*read-eks-cluster.*" + - ".*nextrc2.*" + - ".*stage2.*" + - ".*prod2.*" + - ".*security.*" + - "es-logs$" + - ".*automation.*" diff --git a/easyeffects/.config/easyeffects/Philips SHP9600 ParametricEq.txt b/easyeffects/.config/easyeffects/Philips SHP9600 ParametricEq.txt new file mode 100644 index 0000000..0c3e902 --- /dev/null +++ b/easyeffects/.config/easyeffects/Philips SHP9600 ParametricEq.txt @@ -0,0 +1,11 @@ +Preamp: -11.82 dB +Filter 1: ON LSC Fc 105.0 Hz Gain 16.1 dB Q 0.70 +Filter 2: ON PK Fc 41.6 Hz Gain -1.2 dB Q 3.28 +Filter 3: ON PK Fc 66.6 Hz Gain -12.9 dB Q 0.50 +Filter 4: ON PK Fc 1411.0 Hz Gain 0.5 dB Q 2.99 +Filter 5: ON PK Fc 1826.8 Hz Gain 5.0 dB Q 0.84 +Filter 6: ON PK Fc 1942.0 Hz Gain 0.9 dB Q 4.36 +Filter 7: ON PK Fc 2590.0 Hz Gain -1.9 dB Q 4.42 +Filter 8: ON PK Fc 6008.2 Hz Gain -4.0 dB Q 6.00 +Filter 9: ON PK Fc 7739.3 Hz Gain -1.4 dB Q 4.50 +Filter 10: ON HSC Fc 10000.0 Hz Gain -2.3 dB Q 0.70 diff --git a/easyeffects/.config/easyeffects/input/microphone.json b/easyeffects/.config/easyeffects/input/microphone.json new file mode 100644 index 0000000..f667ca6 --- /dev/null +++ b/easyeffects/.config/easyeffects/input/microphone.json @@ -0,0 +1,102 @@ +{ + "input": { + "autogain#0": { + "bypass": false, + "input-gain": 0.0, + "maximum-history": 15, + "output-gain": 0.0, + "reference": "Geometric Mean (MSI)", + "silence-threshold": -70.0, + "target": -23.0 + }, + "blocklist": [], + "gate#0": { + "attack": 40.0, + "bypass": false, + "curve-threshold": -57.0, + "curve-zone": -6.0, + "dry": -14.0, + "hpf-frequency": 100.0, + "hpf-mode": "24 dB/oct", + "hysteresis": false, + "hysteresis-threshold": -12.0, + "hysteresis-zone": -6.0, + "input-gain": 0.0, + "lpf-frequency": 1000.0, + "lpf-mode": "24 dB/oct", + "makeup": 0.0, + "output-gain": 0.0, + "reduction": -72.0, + "release": 800.0, + "sidechain": { + "input": "Internal", + "lookahead": 8.0, + "mode": "RMS", + "preamp": 0.0, + "reactivity": 10.0, + "source": "Middle", + "stereo-split-source": "Left/Right" + }, + "stereo-split": false, + "wet": -16.0 + }, + "limiter#0": { + "alr": true, + "alr-attack": 5.0, + "alr-knee": 0.0, + "alr-release": 50.0, + "attack": 5.0, + "bypass": false, + "dithering": "24bit", + "external-sidechain": false, + "gain-boost": false, + "input-gain": 0.0, + "lookahead": 5.0, + "mode": "Exp Tail", + "output-gain": 0.0, + "oversampling": "Full x2(2L)", + "release": 5.0, + "sidechain-preamp": 0.0, + "stereo-link": 100.0, + "threshold": 0.0 + }, + "plugins_order": [ + "rnnoise#0", + "gate#0", + "autogain#0", + "limiter#0", + "stereo_tools#0" + ], + "rnnoise#0": { + "bypass": false, + "enable-vad": true, + "input-gain": 0.0, + "model-path": "", + "output-gain": 0.0, + "release": 20.0, + "vad-thres": 50.0, + "wet": 0.0 + }, + "stereo_tools#0": { + "balance-in": 0.0, + "balance-out": 0.0, + "bypass": false, + "delay": -3.469446951953614e-18, + "input-gain": 0.0, + "middle-level": 0.0, + "middle-panorama": 0.0, + "mode": "LR > LL (Mono Left Channel)", + "mutel": false, + "muter": false, + "output-gain": 0.0, + "phasel": false, + "phaser": false, + "sc-level": 1.0, + "side-balance": 0.0, + "side-level": 0.0, + "softclip": false, + "stereo-base": 0.0, + "stereo-phase": 0.0 + } + } +} diff --git a/font-manager.sh b/font-manager.sh new file mode 100755 index 0000000..e0131a9 --- /dev/null +++ b/font-manager.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# ~/.local/bin/font-manager +# This script extracts font archives and rebuilds font cache + +FONT_DIR="$HOME/.local/share/fonts" +ARCHIVE_DIR="$FONT_DIR/archives" +ACTIVE_DIR="$FONT_DIR/active" + +# Function to extract a specific font archive +extract_font() { + local archive="$1" + if [ -f "$ARCHIVE_DIR/$archive.tar.gz" ]; then + echo "Extracting $archive fonts..." + tar -xzf "$ARCHIVE_DIR/$archive.tar.gz" -C "$ACTIVE_DIR" + fc-cache -f + echo "Done! $archive fonts are now active." + else + echo "Error: Font archive $archive.tar.gz not found." + exit 1 + fi +} + +# Function to list available font archives +list_fonts() { + echo "Available font archives:" + ls -1 "$ARCHIVE_DIR" | sed 's/\.tar\.gz$//' +} + +# Function to rebuild font cache +rebuild_cache() { + echo "Rebuilding font cache..." + fc-cache -f + echo "Done!" +} + +# Function to extract all fonts +extract_all() { + echo "Extracting all font archives..." + for archive in "$ARCHIVE_DIR"/*.tar.gz; do + tar -xzf "$archive" -C "$ACTIVE_DIR" + done + fc-cache -f + echo "Done! All fonts are now active." +} + +# Function to clean active fonts directory +clean_fonts() { + echo "Cleaning active fonts directory..." + find "$ACTIVE_DIR" -type f -name "*.ttf" -o -name "*.otf" | xargs rm -f + echo "Done! Active fonts directory is now clean." +} + +# Main script logic +case "$1" in +"extract") + extract_font "$2" + ;; +"list") + list_fonts + ;; +"rebuild") + rebuild_cache + ;; +"all") + extract_all + ;; +"clean") + clean_fonts + ;; +*) + echo "Usage: font-manager [command] [options]" + echo "Commands:" + echo " extract [name] Extract specific font archive" + echo " list List available font archives" + echo " rebuild Rebuild font cache" + echo " all Extract all font archives" + echo " clean Remove all active fonts" + ;; +esac diff --git a/fonts/.local/share/fonts/active/.gitkeep b/fonts/.local/share/fonts/active/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/fonts/.local/share/fonts/archives/AGaramond.tar.gz b/fonts/.local/share/fonts/archives/AGaramond.tar.gz new file mode 100644 index 0000000..4e9b607 Binary files /dev/null and b/fonts/.local/share/fonts/archives/AGaramond.tar.gz differ diff --git a/fonts/.local/share/fonts/archives/FontAwesome.tar.gz b/fonts/.local/share/fonts/archives/FontAwesome.tar.gz new file mode 100644 index 0000000..4f89a4f Binary files /dev/null and b/fonts/.local/share/fonts/archives/FontAwesome.tar.gz differ diff --git a/fonts/.local/share/fonts/archives/Inter.tar.gz b/fonts/.local/share/fonts/archives/Inter.tar.gz new file mode 100644 index 0000000..3484c92 Binary files /dev/null and b/fonts/.local/share/fonts/archives/Inter.tar.gz differ diff --git a/fonts/.local/share/fonts/archives/JetBrains.tar.gz b/fonts/.local/share/fonts/archives/JetBrains.tar.gz new file mode 100644 index 0000000..9c3cb3c Binary files /dev/null and b/fonts/.local/share/fonts/archives/JetBrains.tar.gz differ diff --git a/fonts/.local/share/fonts/archives/MonoLisa.tar.gz b/fonts/.local/share/fonts/archives/MonoLisa.tar.gz new file mode 100644 index 0000000..4176fcf Binary files /dev/null and b/fonts/.local/share/fonts/archives/MonoLisa.tar.gz differ diff --git a/fonts/.local/share/fonts/archives/NerdFonts.tar.gz b/fonts/.local/share/fonts/archives/NerdFonts.tar.gz new file mode 100644 index 0000000..0690e9c Binary files /dev/null and b/fonts/.local/share/fonts/archives/NerdFonts.tar.gz differ diff --git a/fonts/.local/share/fonts/archives/OpenSans.tar.gz b/fonts/.local/share/fonts/archives/OpenSans.tar.gz new file mode 100644 index 0000000..b8803c2 Binary files /dev/null and b/fonts/.local/share/fonts/archives/OpenSans.tar.gz differ diff --git a/fonts/.local/share/fonts/archives/Proxima.tar.gz b/fonts/.local/share/fonts/archives/Proxima.tar.gz new file mode 100644 index 0000000..5935c54 Binary files /dev/null and b/fonts/.local/share/fonts/archives/Proxima.tar.gz differ diff --git a/fonts/.local/share/fonts/archives/SourceSans.tar.gz b/fonts/.local/share/fonts/archives/SourceSans.tar.gz new file mode 100644 index 0000000..3790f0c Binary files /dev/null and b/fonts/.local/share/fonts/archives/SourceSans.tar.gz differ diff --git a/fuzzel/.config/fuzzel/fuzzel.ini b/fuzzel/.config/fuzzel/fuzzel.ini new file mode 100644 index 0000000..d36fb4c --- /dev/null +++ b/fuzzel/.config/fuzzel/fuzzel.ini @@ -0,0 +1,18 @@ +dpi-aware=yes +icon-theme=Papirus-Dark +width=50 +font=Fira Code:size=16 +fields=name,generic,comment,categories,filename,keywords +terminal=kitty +prompt="❯ " +show-actions=yes +exit-on-keyboard-focus-loss=yes +include=~/.config/fuzzel/mocha/red.ini +width=70 + +[border] +radius=20 + +[dmenu] +exit-immediately-if-empty=yes + diff --git a/fuzzel/.config/fuzzel/mocha/blue.ini b/fuzzel/.config/fuzzel/mocha/blue.ini new file mode 100644 index 0000000..0c54d24 --- /dev/null +++ b/fuzzel/.config/fuzzel/mocha/blue.ini @@ -0,0 +1,8 @@ +[colors] +background=1e1e2edd +text=cdd6f4ff +match=89b4faff +selection=585b70ff +selection-match=89b4faff +selection-text=cdd6f4ff +border=b4befeff diff --git a/fuzzel/.config/fuzzel/mocha/flamingo.ini b/fuzzel/.config/fuzzel/mocha/flamingo.ini new file mode 100644 index 0000000..bfe863b --- /dev/null +++ b/fuzzel/.config/fuzzel/mocha/flamingo.ini @@ -0,0 +1,8 @@ +[colors] +background=1e1e2edd +text=cdd6f4ff +match=f2cdcdff +selection=585b70ff +selection-match=f2cdcdff +selection-text=cdd6f4ff +border=b4befeff diff --git a/fuzzel/.config/fuzzel/mocha/green.ini b/fuzzel/.config/fuzzel/mocha/green.ini new file mode 100644 index 0000000..d97bd84 --- /dev/null +++ b/fuzzel/.config/fuzzel/mocha/green.ini @@ -0,0 +1,8 @@ +[colors] +background=1e1e2edd +text=cdd6f4ff +match=a6e3a1ff +selection=585b70ff +selection-match=a6e3a1ff +selection-text=cdd6f4ff +border=b4befeff diff --git a/fuzzel/.config/fuzzel/mocha/lavender.ini b/fuzzel/.config/fuzzel/mocha/lavender.ini new file mode 100644 index 0000000..9ce88df --- /dev/null +++ b/fuzzel/.config/fuzzel/mocha/lavender.ini @@ -0,0 +1,8 @@ +[colors] +background=1e1e2edd +text=cdd6f4ff +match=b4befeff +selection=585b70ff +selection-match=b4befeff +selection-text=cdd6f4ff +border=b4befeff diff --git a/fuzzel/.config/fuzzel/mocha/maroon.ini b/fuzzel/.config/fuzzel/mocha/maroon.ini new file mode 100644 index 0000000..8eac13c --- /dev/null +++ b/fuzzel/.config/fuzzel/mocha/maroon.ini @@ -0,0 +1,8 @@ +[colors] +background=1e1e2edd +text=cdd6f4ff +match=eba0acff +selection=585b70ff +selection-match=eba0acff +selection-text=cdd6f4ff +border=b4befeff diff --git a/fuzzel/.config/fuzzel/mocha/mauve.ini b/fuzzel/.config/fuzzel/mocha/mauve.ini new file mode 100644 index 0000000..0a0cdcc --- /dev/null +++ b/fuzzel/.config/fuzzel/mocha/mauve.ini @@ -0,0 +1,8 @@ +[colors] +background=1e1e2edd +text=cdd6f4ff +match=cba6f7ff +selection=585b70ff +selection-match=cba6f7ff +selection-text=cdd6f4ff +border=b4befeff diff --git a/fuzzel/.config/fuzzel/mocha/peach.ini b/fuzzel/.config/fuzzel/mocha/peach.ini new file mode 100644 index 0000000..60e02a9 --- /dev/null +++ b/fuzzel/.config/fuzzel/mocha/peach.ini @@ -0,0 +1,8 @@ +[colors] +background=1e1e2ef0 +text=cdd6f4ff +match=fab387ff +selection=585b70ff +selection-match=fab387ff +selection-text=cdd6f4ff +border=b4befeff diff --git a/fuzzel/.config/fuzzel/mocha/pink.ini b/fuzzel/.config/fuzzel/mocha/pink.ini new file mode 100644 index 0000000..302f354 --- /dev/null +++ b/fuzzel/.config/fuzzel/mocha/pink.ini @@ -0,0 +1,8 @@ +[colors] +background=1e1e2edd +text=cdd6f4ff +match=f5c2e7ff +selection=585b70ff +selection-match=f5c2e7ff +selection-text=cdd6f4ff +border=b4befeff diff --git a/fuzzel/.config/fuzzel/mocha/red.ini b/fuzzel/.config/fuzzel/mocha/red.ini new file mode 100644 index 0000000..b6af6ae --- /dev/null +++ b/fuzzel/.config/fuzzel/mocha/red.ini @@ -0,0 +1,8 @@ +[colors] +background=1e1e2ef0 +text=cdd6f4ff +match=f38ba8ff +selection=585b70ff +selection-match=f38ba8ff +selection-text=cdd6f4ff +border=b4befeff diff --git a/fuzzel/.config/fuzzel/mocha/rosewater.ini b/fuzzel/.config/fuzzel/mocha/rosewater.ini new file mode 100644 index 0000000..b339c31 --- /dev/null +++ b/fuzzel/.config/fuzzel/mocha/rosewater.ini @@ -0,0 +1,8 @@ +[colors] +background=1e1e2edd +text=cdd6f4ff +match=f5e0dcff +selection=585b70ff +selection-match=f5e0dcff +selection-text=cdd6f4ff +border=b4befeff diff --git a/fuzzel/.config/fuzzel/mocha/sapphire.ini b/fuzzel/.config/fuzzel/mocha/sapphire.ini new file mode 100644 index 0000000..2c94335 --- /dev/null +++ b/fuzzel/.config/fuzzel/mocha/sapphire.ini @@ -0,0 +1,8 @@ +[colors] +background=1e1e2edd +text=cdd6f4ff +match=74c7ecff +selection=585b70ff +selection-match=74c7ecff +selection-text=cdd6f4ff +border=b4befeff diff --git a/fuzzel/.config/fuzzel/mocha/sky.ini b/fuzzel/.config/fuzzel/mocha/sky.ini new file mode 100644 index 0000000..ee57600 --- /dev/null +++ b/fuzzel/.config/fuzzel/mocha/sky.ini @@ -0,0 +1,8 @@ +[colors] +background=1e1e2edd +text=cdd6f4ff +match=89dcebff +selection=585b70ff +selection-match=89dcebff +selection-text=cdd6f4ff +border=b4befeff diff --git a/fuzzel/.config/fuzzel/mocha/teal.ini b/fuzzel/.config/fuzzel/mocha/teal.ini new file mode 100644 index 0000000..5387e67 --- /dev/null +++ b/fuzzel/.config/fuzzel/mocha/teal.ini @@ -0,0 +1,8 @@ +[colors] +background=1e1e2edd +text=cdd6f4ff +match=94e2d5ff +selection=585b70ff +selection-match=94e2d5ff +selection-text=cdd6f4ff +border=b4befeff diff --git a/fuzzel/.config/fuzzel/mocha/yellow.ini b/fuzzel/.config/fuzzel/mocha/yellow.ini new file mode 100644 index 0000000..343f534 --- /dev/null +++ b/fuzzel/.config/fuzzel/mocha/yellow.ini @@ -0,0 +1,8 @@ +[colors] +background=1e1e2edd +text=cdd6f4ff +match=f9e2afff +selection=585b70ff +selection-match=f9e2afff +selection-text=cdd6f4ff +border=b4befeff diff --git a/git/.config/git/commit.sh b/git/.config/git/commit.sh new file mode 100755 index 0000000..7ecd00d --- /dev/null +++ b/git/.config/git/commit.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +get_ticket_number() { + git symbolic-ref --short HEAD | grep -Ei '^ocst-[0-9]{2,5}-' | sed -E 's/^(ocst-[0-9]{2,5}).*$/\1/i' | tr '[:upper:]' '[:lower:]' +} + +format_commit_message() { + local message="$1" + local ticket="$2" + + if echo "$message" | grep -E '^[^:]+:' >/dev/null; then + local type=$(echo "$message" | cut -d: -f1) + local content=$(echo "$message" | cut -d: -f2- | sed 's/^ //') + echo "$type($ticket): $content" + else + echo "$message" + fi +} + +main() { + local ticket=$(get_ticket_number) + if [ -n "$ticket" ]; then + git commit -m "$(format_commit_message "$1" "$ticket")" "${@:2}" + else + git commit -m "$1" "${@:2}" + fi +} + +main "$@" diff --git a/git/.config/git/config b/git/.config/git/config new file mode 100644 index 0000000..7325fb1 --- /dev/null +++ b/git/.config/git/config @@ -0,0 +1,82 @@ +# GitFlow related sections +[gitflow "branch"] + master = master + develop = develop + +[gitflow "prefix"] + feature = feature/ + release = release/ + hotfix = hotfix/ + bugfix = bugfix/ + support = support/ + versiontag = v + +[user] + email = marianoz@posteo.net + name = Mariano Z. + signingkey = 13D35660EC8E8AA03D4370A83FA93CB876C8FFAA + + +[include] + path = ~/.config/git/gitalias.txt +[core] + pager = diff-so-fancy | less --tabs=4 -RFX + autocrlf = input + excludesfile = ~/.config/git/.gitignore +[color] + ui = true +[color "diff-highlight"] + oldNormal = red bold + oldHighlight = red bold 52 + newNormal = green bold + newHighlight = green bold 22 +[color "diff"] + meta = yellow + frag = magenta bold + commit = yellow bold + old = red bold + new = green bold + whitespace = red reverse +[credential] + helper = /usr/lib/git-core/git-credential-libsecret +[mergetool "fugitive"] + cmd = vim -f -c "MergetoolStart" "$MERGED" "$BASE" "$LOCAL" "$REMOTE" + #cmd = vim -f -c \"Gvdiffsplit!\" \"$MERGED\" +[merge] + tool = fugitive + conflictStyle = diff3 +[icdiff] + options = --highlight --line-numbers +# +[pull] + rebase = true +[rebase] + autoStash = true +[init] + defaultBranch = master +[push] + autoSetupRemote = true + +# avoid issues where the `cargo audit` command tries to clone from a repo you do not have WRITE access to. +# we already use SSH for every github repo, and so this puts the clone back to using HTTPS. +[url "https://github.com/RustSec/advisory-db"] + insteadOf = https://github.com/RustSec/advisory-db + +[filter "lfs"] + clean = git-lfs clean -- %f + smudge = git-lfs smudge -- %f + process = git-lfs filter-process + required = true + +[color "blame"] + highlightRecent = 237, 20 month ago, 238, 19 month ago, 239, 18 month ago, 240, 17 month ago, 241, 16 month ago, 242, 15 month ago, 243, 14 month ago, 244, 13 month ago, 245, 12 month ago, 246, 11 month ago, 247, 10 month ago, 248, 9 month ago, 249, 8 month ago, 250, 7 month ago, 251, 6 month ago, 252, 5 month ago, 253, 4 month ago, 254, 3 month ago, 231, 2 month ago, 230, 1 month ago, 229, 3 weeks ago, 228, 2 weeks ago, 227, 1 week ago, 226 + +[commit] + gpgsign = true + +[alias] + bb = !better-git-branch.sh + + +[includeIf "gitdir:~/Sync/"] + path = ~/Sync/Obsidian/.gitconfig diff --git a/git/.config/git/gitalias.txt b/git/.config/git/gitalias.txt new file mode 100644 index 0000000..2493276 --- /dev/null +++ b/git/.config/git/gitalias.txt @@ -0,0 +1,1513 @@ +# -*- mode: gitconfig; -*- +# vim: set filetype=gitconfig: +## +# GitAlias.com file of many git alias items, including shortcuts, helpers, workflows, etc. +# +# +# ## Usage +# +# Typical usage for a typical user: +# +# * Save this file as a dot file in your home directory: `~/.gitalias.txt` +# +# * Edit your git config dot file in your home directory such as `~/.gitconfig` +# +# * Include the path to this file. +# +# Example file `~/.gitconfig` with an entry to include the file `~/.gitalias.txt`: +# +# [include] +# path = gitalias.txt +# +# +# ## Usage for older git versions +# +# If you use an older version of git that does not have git config "include" capability, +# or if you prefer more control, then you can simply copy/paste anything you like from +# this file to your own git config file. +# +# +# ## Customization +# +# If you want to use this file, and also want to change some of the items, +# then one way is to use your git config file to include this gitalias file, +# and also define your own alias items; a later alias takes precedence. +# +# Example file `~/.gitconfig` item to include the file `~/.gitalias.txt`: +# +# [include] +# path = ~/.gitconfig.d/gitalias.txt +# [alias] +# l = log --graph --oneline +# +# +# ## Links +# +# * [GitAlias.com website](http://gitalias.com) +# * [GitAlias GitHub](https://github.com/gitalias) +# * [Git Basics - Git Aliases](https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases) +# * [Git Basics - Tips and Tricks](https://git-scm.com/book/en/v1/Git-Basics-Tips-and-Tricks) +# +# ## Tracking +# +# * Package: gitalias +# * Version: 23.2.0 +# * Created: 2016-06-17T00:00:00Z +# * Updated: 2020-07-10T01:08:58Z +# * License: GPL-2.0-only +# * Contact: Joel Parker Henderson (joel@joelparkerhenderson.com) +## + +[alias] + + ## + # One letter alias for our most frequent commands. + # + # Guidelines: these aliases do not use options, because we want + # these aliases to be easy to compose and use in many ways. + ## + + a = add + b = branch + c = commit + d = diff + f = fetch + g = grep + l = log + m = merge + o = checkout + p = pull + r = remote + s = status + w = whatchanged + + ## + # Short aliases for our frequent commands. + # + # Guidelines: + # + # * Generally speaking, the alias should be in the same + # order as the command name followed by its options. + # + # * Right: fb = foo --bar + # * Wrong: bf = foo --bar + ## + + ### add ### + + # add all + aa = add --all + + # add by patch - looks at each change, and asks if we want to put it in the repo. + ap = add --patch + + # add just the files that are updated. + au = add --update + + ### branch ### + + # branch description + bd = !"git config branch.$(git rev-parse --abbrev-ref HEAD 2>/dev/null).description" + + # bra nch - edit the description + be = branch --edit-description + + # branch and only list branches whose tips are reachable from the specified commit (HEAD if not specified). + bm = branch --merged + + # branch and only list branches whose tips are not reachable from the specified commit (HEAD if not specified). + bnm = branch --no-merged + + ### commit ### + + # commit - amend the tip of the current branch rather than creating a new commit. + ca = commit --amend + + # commit - amend the tip of the current branch, and edit the message. + cam = commit --amend --message + + # commit - amend the tip of the current branch, and do not edit the message. + cane = commit --amend --no-edit + + # commit interactive + ci = commit --interactive + + # commit with a message + cm = "!sh $XDG_CONFIG_HOME/git/commit.sh" + + + ### checkout ### + + # checkout - update the working tree to match a branch or paths. [same as "o" for "out"] + co = checkout + con = checkout --no-guess + + ### cherry-pick ### + + # cherry-pick - apply the changes introduced by some existing commits; useful for moving small chunks of code between branches. + cp = cherry-pick + + # cherry-pick - abort the picking process + cpa = cherry-pick --abort + + # cherry-pick - continue the picking process + cpc = cherry-pick --continue + + # cherry-pick without making a commit, and when when recording the commit, append a line that says "(cherry picked from commit ...)" + cp-nx = cherry-pick --no-commit -x + + ### diff ### + + # diff - show changes not yet staged + dc = diff --cached + + # diff - show changes about to be commited + ds = diff --staged + + # diff - show changes but by word, not line + dw = diff --word-diff + + # diff deep - show changes with our preferred options. Also aliased as `diff-deep`. + dd = diff --check --dirstat --find-copies --find-renames --histogram --color + + ### clean ### + + # clean everything to be pristine + cleanest = clean -ffdx + + ### grep ### + + # grep i.e. search for text + g = grep + + # grep - show line number + gl = grep --line-number + + # grep group - search with our preferred options. Also aliased as `grep-group`. + gg = grep --break --heading --line-number --color + + ### log ### + + # log with a text-based graphical representation of the commit history. + lg = log --graph + + # log with one line per item. + lo = log --oneline + + # log with patch generation. + lp = log --patch + + # log with first parent, useful for team branch that only accepts pull requests + lfp = log --first-parent + + # log with items appearing in topological order, i.e. descendant commits are shown before their parents. + lt = log --topo-order + + # log like - we like this summarization our key performance indicators. Also aliased as `log-like`. + ll = log --graph --topo-order --date=short --abbrev-commit --decorate --all --boundary --pretty=format:'%Cgreen%ad %Cred%h%Creset -%C(yellow)%d%Creset %s %Cblue[%cn]%Creset %Cblue%G?%Creset' + + # log like long - we like this summarization our key performance indicators. Also aliased as `log-like-long`. + lll = log --graph --topo-order --date=iso8601-strict --no-abbrev-commit --abbrev=40 --decorate --all --boundary --pretty=format:'%Cgreen%ad %Cred%h%Creset -%C(yellow)%d%Creset %s %Cblue[%cn <%ce>]%Creset %Cblue%G?%Creset' + + # + l = log --graph --pretty='format:%C(red)%d%C(reset) %C(yellow)%h%C(reset) %ar %C(green)%aN%C(reset) %s' + ## ls-files ## + + # ls-files - show information about files in the index and the working tree; like Unix "ls" command. + ls = ls-files + + # ls-ignored - list files that git has ignored. + ls-ignored = ls-files --others --i --exclude-standard + + ### merge ### + + # merge abort - cancel the merging process + ma = merge --abort + + # merge - continue the merging process + mc = merge --continue + + # merge but without autocommit, and with a commit even if the merge resolved as a fast-forward. + me = merge --no-commit --no-ff + + ### pull ### + + # pull if a merge can be resolved as a fast-forward, otherwise fail. + pf = pull --ff-only + + # pull with rebase - to provide a cleaner, linear, bisectable history. + # + # To automatically do "pull --rebase" everywhere: + # + # git config --global pull.rebase true + # + # To automatically do "pull --rebase" for any branch based on master: + # + # git config branch.master.rebase true + # + # To automatically do "pull --rebase" for any newly-created branches: + # + # git config --global branch.autosetuprebase always + # + # To integrate changes between branches, you can merge or rebase. + # + # When we use "git pull", git does a fetch then a merge. + # If we've made changes locally and someone else has pushed changes + # to our git host then git will automatically merge these together + # and create a merge commit that looks like this in the history: + # + # 12345678 - Merge branch 'foo' of bar into master + # + # When we use "git pull --rebase", git does a fetch then a rebase. + # A rebase resets the HEAD of your local branch to be the same as + # the remote HEAD, then replays your local commits back into repo. + # This means you don't get any noisy merge messages in your history. + # This gives us a linear history, and also helps with git bisect. + # + pr = pull --rebase + + # pp - pull with rebase preserve of merge commits + # + # See https://stackoverflow.com/questions/21364636/git-pull-rebase-preserve-merges + # + # You should only rebase if you know (in a sort of general sense) + # what you are doing, and if you do know what you are doing, then you + # would probably prefer a merge-preserving rebase as a general rule. + # + # Although by the time you've decided that rebasing is a good idea, + # you will probably find that a history that has its own embedded + # branch-and-merge-points is not necessarily the correct "final + # rewritten history". + # + # That is, if it's appropriate to do a rebase at all, it's at least fairly + # likely that the history to be rebased is itself linear, so that the + # preserve-vs-flatten question is moot anyway. + # + # See https://stackoverflow.com/questions/38269092/is-it-possible-to-put-preserve-merges-in-the-gitconfig + # + # While preserving merges is probably generally superior, in at least a + # few ways, to discarding them when rebasing, the fact is that rebase + # cannot preserve them. The only thing it can do, once some commits + # have been copied to new commits, is re-perform them. This can have new + # and/or different merge conflicts, vs the last time the merge was done. + # You should also pay close attention to the restrictions on merge + # preservation in the git rebase documentation. + # + # Without getting into a lot of detail, it always seems to me that most + # commit graph subsets that "should be" rebased, rarely have any + # internal merges. If such a graph subset has a single final merge, you + # can simply strip away that merge (with git reset) before rebasing, + # and re-do that single merge manually at the end. (In fact, git rebase + # normally drops merge commits entirely, so you don't have to run the git + # reset itself in some cases. The one where you do have to run it is when + # the merge is into the branch onto which you intend to rebase. This is + # where git pull actually does the right thing when it uses + # `git rebase -p`, except that it fails to check for, and warn about, + # internal merges, which are sort of warning signs that rebasing might + # not be a good idea. + # + pp = pull --rebase=preserve + + ### rebase ### + + # rebase - forward-port local commits to the updated upstream head. + rb = rebase + + # rebase abort - cancel the rebasing process + rba = rebase --abort + + # rebase - continue the rebasing process after resolving a conflict manually and updating the index with the resolution. + rbc = rebase --continue + + # rebase - restart the rebasing process by skipping the current patch. + rbs = rebase --skip + + # rbi - rebase interactive on our unpushed commits. + # + # Before we push our local changes, we may want to do some cleanup, + # to improve our commit messages or squash related commits together. + # + # Let's say I've pushed two commits that are related to a new feature and + # I have another where I made a spelling mistake in the commit message. + # When I run "git rbi" I get dropped into my editor with this: + # + # pick 7f06d36 foo + # pick ad544d0 goo + # pick de3083a hoo + # + # Let's say I want to squash the "foo" and "goo" commits together, + # and also change "hoo" to say "whatever". To do these, I change "pick" + # to say "s" for squash; this tells git to squash the two together; + # I also edit "hoo" to rename it to "whatever". I make the file look like: + # + # pick 7f06d36 foo + # s ad544d0 goo + # r de3083a whatever + # + # This gives me two new commit messages to edit, which I update. + # Now when I push the remote repo host receives two commits + # + # 3400455 - foo + # 5dae0a0 - whatever + # + rbi = rebase --interactive @{upstream} + + # See https://blog.filippo.io/git-fixup-amending-an-older-commit/ + # This is a slightly modified version + fixup = "!f() { TARGET=$(git rev-parse \"$1\"); git commit --fixup=$TARGET && GIT_EDITOR=true git rebase --interactive --autosquash $TARGET~; }; f" + + ### reflog ### + + # reflog - reference log that manages when tips of branches are updated. + rl = reflog + + ### remote ### + + # remote - manage set of tracked repositories [same as "r"]. + rr = remote + + # remote show - gives some information about the remote . + rrs = remote show + + # remote update - fetch updates for a named set of remotes in the repository as defined by remotes. + rru = remote update + + # remote prune - deletes all stale remote-tracking branches under . + rrp = remote prune + + incoming = !git remote update --prune; git log ..@{upstream} + outgoing = log @{upstream}.. + + # Push to all remotes + push-to-all-remotes = !git remote | xargs -I% -n1 git push % + + ### revert ### + + # revert - undo the changes from some existing commits + rv = revert + + # revert without autocommit; useful when you're reverting more than one commits' effect to your index in a row. + rvnc = revert --no-commit + + ### show-branch ### + + # show-branch - print a list of branches and their commits. + sb = show-branch + + ### submodule ### + + # submodule - enables foreign repositories to be embedded within a dedicated subdirectory of the source tree. + sm = submodule + + # submodule init + smi = submodule init + + # submodule add + sma = submodule add + + # submodule sync + sms = submodule sync + + # submodule update + smu = submodule update + + # submodule update with initialize + smui = submodule update --init + + # submodule update with initialize and recursive; this is useful to bring a submodule fully up to date. + smuir = submodule update --init --recursive + + ### status ### + + # status with short format instead of full details + ss = status --short + + # status with short format and showing branch and tracking info. + ssb = status --short --branch + + ### ALIAS MANAGEMENT ### + + # Show our defined alias list + aliases = "!git config --get-regexp '^alias\\.' | cut -c 7- | sed 's/ / = /'" + + add-alias = "!f() { [ $# = 3 ] && git config $1 alias.\"$2\" \"$3\" && return 0 || echo \"Usage: git add-(local|global)-alias \" >&2 && return 1; }; f" + add-global-alias = "!git add-alias --global" + add-local-alias = "!git add-alias --local" + + # Rename an alias + rename-alias = "!f() { [ $# = 3 ] && [ $2 != $3 ] && [ ! -z \"$(git config $1 --get alias.$2)\" ] && [ -z \"$(git config $1 --get alias.$3)\" ] && git config $1 alias.$3 \"$(git config $1 --get alias.$2)\" && git config $1 --unset alias.$2 && return 0 || echo \"Usage: git rename-(local|global)-alias \nThe alias you are going to rename must exist and new name must not exist.\" >&2 && return 1; };f" + rename-global-alias = "!git rename-alias --global" + rename-local-alias = "!git rename-alias --local" + + # Last tag in the current branch + lasttag = describe --tags --abbrev=0 + + # Latest annotated tag in all branches + lasttagged = !git describe --tags `git rev-list --tags --max-count=1` + + # From https://gist.github.com/492227 + head = log -n1 + heads = !"git log origin/master.. --format='%Cred%h%Creset;%C(yellow)%an%Creset;%H;%Cblue%f%Creset' | git name-rev --stdin --always --name-only | column -t -s';'" + lost = !"git fsck | awk '/dangling commit/ {print $3}' | git show --format='SHA1: %C(yellow)%h%Creset %f' --stdin | awk '/SHA1/ {sub(\"SHA1: \", \"\"); print}'" + + ### diff-* ### + + diff-all = !"for name in $(git diff --name-only $1); do git difftool $1 $name & done" + diff-changes = diff --name-status -r + diff-stat = diff --stat --ignore-space-change -r + diff-staged = diff --cached + + # Diff using our preferred options. A.k.a. `dd`. + diff-deep = diff --check --dirstat --find-copies --find-renames --histogram --color + + ### grep-* ### + + # Find text in any commit ever. + grep-all = !"f() { git rev-list --all | xargs git grep \"$@\"; }; f" + + # Find text and group the output lines. A.k.a. `gg`. + grep-group = grep --break --heading --line-number --color + + # grep with ack-like formatting + grep-ack = \ + -c color.grep.linenumber=\"bold yellow\" \ + -c color.grep.filename=\"bold green\" \ + -c color.grep.match=\"reverse yellow\" \ + grep --break --heading --line-number + + ### init ### + + # initalize a repo and immediate add an empty commit, which makes rebase easier. + init-empty = !"f() { git init && git commit --allow-empty --allow-empty-message --message ''; }; f" + + ### merge-* ### + + # Given a merge commit, find the span of commits that exist(ed). + # Not so useful in itself, but used by other aliases. + # Thanks to Rob Miller for the merge-span-* aliaes. + merge-span = !"f() { echo $(git log -1 $2 --merges --pretty=format:%P | cut -d' ' -f1)$1$(git log -1 $2 --merges --pretty=format:%P | cut -d' ' -f2); }; f" + + # Find the commits that were introduced by a merge + merge-span-log = "!git log `git merge-span .. $1`" + + # Show the changes that were introduced by a merge + merge-span-diff = !"git diff `git merge-span ... $1`" + + # Show the changes that were introduced by a merge, in your difftool + merge-span-difftool = !"git difftool `git merge-span ... $1`" + + # Interactively rebase all the commits on the current branch + rebase-branch = !"git rebase --interactive `git merge-base master HEAD`" + + # Sort by date for branches; can be useful for spring cleaning + refs-by-date = for-each-ref --sort=-committerdate --format='%(committerdate:short) %(refname:short)' + + # Find all objects that aren't referenced by any other object (orphans). + # To help an orphan, we create a new branch with the orphan's commit hash, + # then merge it into our current branch: + # + # git branch foo + # git merge foo + # + orphans = fsck --full + + # List all blobs by size in bytes. + # By [CodeGnome](http://www.codegnome.com/) + rev-list-all-objects-by-size = !"git rev-list --all --objects | awk '{print $1}'| git cat-file --batch-check | fgrep blob | sort -k3nr" + + # List all objects by size in bytes and file name. + # By [raphinesse](https://stackoverflow.com/users/380229/raphinesse) + rev-list-all-objects-by-size-and-name = !"git rev-list --all --objects | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | awk '/^blob/ {print substr($0,6)}' | sort --numeric-sort --key=2" + + ### LOG ALIASES ### + + # Show log of changes, most recent first + log-changes = log --oneline --reverse + + # Show log of new commits after you fetched, with stats, excluding merges + log-fresh = log ORIG_HEAD.. --stat --no-merges + + # Show log in our preferred format for our key performance indicators. A.k.a. `ll`. + log-like = log --graph --topo-order --date=short --abbrev-commit --decorate --all --boundary --pretty=format:'%Cgreen%ad %Cred%h%Creset -%C(yellow)%d%Creset %s %Cblue[%cn]%Creset %Cblue%G?%Creset' + + # Show log in our preferred format for our key performance indicators, with long items. A.k.a. `lll`. + log-like-long = log --graph --topo-order --date=iso8601-strict --no-abbrev-commit --decorate --all --boundary --pretty=format:'%Cgreen%ad %Cred%h%Creset -%C(yellow)%d%Creset %s %Cblue[%cn <%ce>]%Creset %Cblue%G?%Creset' + + # Show log with dates in our local timezone + log-local = log --date=local + + # Show the log for my own commits by my own user email + log-my = !git log --author $(git config user.email) + + # Show log as a graph + log-graph = log --graph --all --oneline --decorate + + # Show the date of the earliest commit, in strict ISO 8601 format + log-first-date = !"git log --date-order --format=%cI | tail -1" + + # Show the date of the latest commit, in strict ISO 8601 format + log-latest-date = log -1 --date-order --format=%cI + + # Show the log of the recent hour, day, week, month, year + log-hour = log --since=1-hour-ago + log-day = log --since=1-day-ago + log-week = log --since=1-week-ago + log-month = log --since=1-month-ago + log-year = log --since=1-year-ago + + # Show the log of my own recent hour, day, week, month, year + log-my-hour = log --author $(git config user.email) --since=1-hour-ago + log-my-day = log --author $(git config user.email) --since=1-day-ago + log-my-week = log --author $(git config user.email) --since=1-week-ago + log-my-month = log --author $(git config user.email) --since=1-month-ago + log-my-year = log --author $(git config user.email) --since=1-year-ago + + # Show a specific format string and its number of log entries + log-of-format-and-count = "!f() { format=\"$1\"; shift; git log $@ --format=oneline --format="$format" | awk '{a[$0]++}END{for(i in a){print i, a[i], int((a[i]/NR)*100) \"%\"}}' | sort; }; f" + log-of-count-and-format = "!f() { format=\"$1\"; shift; git log $@ --format=oneline --format="$format" | awk '{a[$0]++}END{for(i in a){print a[i], int((a[i]/NR)*100) \"%\", i}}' | sort -nr; }; f" + + # Show the number of log entries by a specific format string and date format string + log-of-format-and-count-with-date = "!f() { format=\"$1\"; shift; date_format=\"$1\"; shift; git log $@ --format=oneline --format=\"$format\" --date=format:\"$date_format\" | awk '{a[$0]++}END{for(i in a){print i, a[i], int((a[i]/NR)*100) \"%\"}}' | sort -r; }; f" + log-of-count-and-format-with-date = "!f() { format=\"$1\"; shift; date_format=\"$1\"; shift; git log $@ --format=oneline --format=\"$format\" --date=format:\"$date_format\" | awk '{a[$0]++}END{for(i in a){print a[i], int((a[i]/NR)*100) \"%\", i}}' | sort -nr; }; f" + + # Show the number of log items by email + log-of-email-and-count = "!f() { git log-of-format-and-count \"%aE\" $@; }; f" + log-of-count-and-email = "!f() { git log-of-count-and-format \"%aE\" $@; }; f" + + # Show the number of log items by hour + log-of-hour-and-count = "!f() { git log-of-format-and-count-with-date \"%ad\" \"%Y-%m-%dT%H\" $@ ; }; f" + log-of-count-and-hour = "!f() { git log-of-count-and-format-with-date \"%ad\" \"%Y-%m-%dT%H\" $@ ; }; f" + + # Show the number of log items by day + log-of-day-and-count = "!f() { git log-of-format-and-count-with-date \"%ad\" \"%Y-%m-%d\" $@ ; }; f" + log-of-count-and-day = "!f() { git log-of-count-and-format-with-date \"%ad\" \"%Y-%m-%d\" $@ ; }; f" + + # Show the number of log items by week + log-of-week-and-count = "!f() { git log-of-format-and-count-with-date \"%ad\" \"%Y#%V\" $@; }; f" + log-of-count-and-week = "!f() { git log-of-count-and-format-with-date \"%ad\" \"%Y#%V\" $@; }; f" + + # Show the number of log items by month + log-of-month-and-count = "!f() { git log-of-format-and-count-with-date \"%ad\" \"%Y-%m\" $@ ; }; f" + log-of-count-and-month = "!f() { git log-of-count-and-format-with-date \"%ad\" \"%Y-%m\" $@ ; }; f" + + # Show the number of log items by year + log-of-year-and-count = "!f() { git log-of-format-and-count-with-date \"%ad\" \"%Y\" $@ ; }; f" + log-of-count-and-year = "!f() { git log-of-count-and-format-with-date \"%ad\" \"%Y\" $@ ; }; f" + + # Show the number of log items by hour of day + log-of-hour-of-day-and-count = "!f() { git log-of-format-and-count-with-date \"%ad\" \"%H\" $@; }; f" + log-of-count-and-hour-of-day = "!f() { git log-of-count-and-format-with-date \"%ad\" \"%H\" $@; }; f" + + # Show the number of log items by day of week + log-of-day-of-week-and-count = "!f() { git log-of-format-and-count-with-date \"%ad\" \"%u\" $@; }; f" + log-of-count-and-day-of-week = "!f() { git log-of-count-and-format-with-date \"%ad\" \"%u\" $@; }; f" + + # Show the number of log items by week of year + log-of-week-of-year-and-count = "!f() { git log-of-format-and-count-with-date \"%ad\" \"%V\" $@; }; f" + log-of-count-and-week-of-year = "!f() { git log-of-count-and-format-with-date \"%ad\" \"%V\" $@; }; f" + + # TODO + log-refs = log --all --graph --decorate --oneline --simplify-by-decoration --no-merges + log-timeline = log --format='%h %an %ar - %s' + log-local = log --oneline origin..HEAD + log-fetched = log --oneline HEAD..origin/master + + # chart: show a summary chart of activity per author. + # + # Example: + # + # $ git chart + # ..X..........X...2..12 alice@example.com + # ....2..2..13.......... bob@example.com + # 2.....1....11......... carol@example.com + # ..1............1..1... david@example.com + # ....1.......1.3.3.22.2 eve@example.com + # + # The chart rows are the authors. + # TODO: sort the rows meaningfully, + # such as alphabetically, or by count. + # + # The chart columns are the days. + # The chart column prints one character per day. + # + # * For 1-9 commits, show the number. + # * For 10 or more commits, show "X" as a visual indicator. + # * For no commits, show "." as a visual placeholder. + # + # The chart timeline adjusts the date range automatically: + # + # * The timeline starts with the date of the earliest commit. + # * The timeline stops with the date of the latest commit. + # * The intent is to show the most relevant information. + # + # The chart default is to look at the past 6 weeks; + # this gives a good balance of recency and speed + # for a team that's currently working on a repo, + # and also gives a good balance of fitting within + # one terminal window 80 character width. + # + # You can adjust how far back the chart looks, + # by providing your own `--since` parameter. + # For example if you want to chart an older repo, + # that does not have any recent commits, then you + # you must provide a longer `--since` parameter. + # + chart = "!f() { \ + git log \ + --format=oneline \ + --format=\"%aE %at\" \ + --since=6-weeks-ago \ + $* | \ + awk ' \ + function time_to_slot(t) { return strftime(\"%Y-%m-%d\", t, true) } \ + function count_to_char(i) { return (i > 0) ? ((i < 10) ? i : \"X\") : \".\" } \ + BEGIN { \ + time_min = systime(); time_max = 0; \ + SECONDS_PER_DAY=86400; \ + } \ + { \ + item = $1; \ + time = 0 + $2; \ + if (time > time_max){ time_max = time } else if (time < time_min){ time_min = time }; \ + slot = time_to_slot(time); \ + items[item]++; \ + slots[slot]++; \ + views[item, slot]++; \ + } \ + END{ \ + printf(\"Chart time range %s to %s.\\n\", time_to_slot(time_min), time_to_slot(time_max)); \ + time_max_add = time_max += SECONDS_PER_DAY; \ + for(item in items){ \ + row = \"\"; \ + for(time = time_min; time < time_max_add; time += SECONDS_PER_DAY) { \ + slot = time_to_slot(time); \ + count = views[item, slot]; \ + row = row count_to_char(count); \ + } \ + print row, item; \ + } \ + }'; \ + }; f" + + # churn: show log of files that have many changes + # + # * Written by (Corey Haines)[http://coreyhaines.com/] + # * Scriptified by Gary Bernhardt + # * Obtained from https://github.com/garybernhardt/dotfiles/blob/master/bin/git-churn + # * Edited for GitAlias.com repo by Joel Parker Henderson + # * Comments by Mislav http://mislav.uniqpath.com/2014/02/hidden-documentation/ + # + # Show churn for whole repo: + # + # $ git churn + # + # Show churn for specific directories: + # + # $ git churn app lib + # + # Show churn for a time range: + # + # $ git churn --since=1-month-ago + # + # These are all standard arguments to `git log`. + # + # It's possible to get valuable insight from history of a project not only + # by viewing individual commits, but by analyzing sets of changes as a whole. + # For instance, `git churn` compiles stats about which files change the most. + # + # For example, to see where work on an app was focused on in the past month: + # + # $ git churn --since=1-month-ago app/ | tail + # + # This can also highlight potential problems with technical debt in a project. + # A specific file changing too often is generally a red flag, since it probably + # means the file either needed to be frequently fixed for bugs, or the file + # holds too much responsibility and should be split into smaller units. + # + # Similar methods of history analysis can be employed to see which people were + # responsible recently for development of a certain part of the codebase. + # + # For instance, to see who contributed most to the API part of an application: + # + # $ git log --format='%an' --since=1-month-ago app/controllers/api/ | \ + # sort | uniq -c | sort -rn | head + # + # 109 Alice Anderson + # 13 Bob Brown + # 7 Carol Clark + # + churn = !"f() { git log --all --find-copies --find-renames --name-only --format='format:' \"$@\" | awk 'NF{a[$0]++}END{for(i in a){print a[i], i}}' | sort -rn;};f" + + # summary: print a helpful summary of some typical metrics + summary = "!f() { \ + printf \"Summary of this branch...\n\"; \ + printf \"%s\n\" $(git rev-parse --abbrev-ref HEAD); \ + printf \"%s first commit timestamp\n\" $(git log --date-order --format=%cI | tail -1); \ + printf \"%s latest commit timestamp\n\" $(git log -1 --date-order --format=%cI); \ + printf \"%d commit count\n\" $(git rev-list --count HEAD); \ + printf \"%d date count\n\" $(git log --format=oneline --format=\"%ad\" --date=format:\"%Y-%m-%d\" | awk '{a[$0]=1}END{for(i in a){n++;} print n}'); \ + printf \"%d tag count\n\" $(git tag | wc -l); \ + printf \"%d author count\n\" $(git log --format=oneline --format=\"%aE\" | awk '{a[$0]=1}END{for(i in a){n++;} print n}'); \ + printf \"%d committer count\n\" $(git log --format=oneline --format=\"%cE\" | awk '{a[$0]=1}END{for(i in a){n++;} print n}'); \ + printf \"%d local branch count\n\" $(git branch | grep -v \" -> \" | wc -l); \ + printf \"%d remote branch count\n\" $(git branch -r | grep -v \" -> \" | wc -l); \ + printf \"\nSummary of this directory...\n\"; \ + printf \"%s\n\" $(pwd); \ + printf \"%d file count via git ls-files\n\" $(git ls-files | wc -l); \ + printf \"%d file count via find command\n\" $(find . | wc -l); \ + printf \"%d disk usage\n\" $(du -s | awk '{print $1}'); \ + printf \"\nMost-active authors, with commit count and %%...\n\"; git log-of-count-and-email | head -7; \ + printf \"\nMost-active dates, with commit count and %%...\n\"; git log-of-count-and-day | head -7; \ + printf \"\nMost-active files, with churn count\n\"; git churn | head -7; \ + }; f" + + ### REF ALIASES ### + + ref-recent = "!git for-each-ref --sort=-committerdate --format='%(committerdate:short) %(refname:short) %(objectname:short) %(contents:subject)' refs/heads/" + + ### LOOKUP ALIASES ### + + # whois: given a string for an author, try to figure out full name and email: + whois = "!sh -c 'git log --regexp-ignore-case -1 --pretty=\"format:%an <%ae>\n\" --author=\"$1\"' -" + + # Given any git object, try to show it briefly + whatis = show --no-patch --pretty='tformat:%h (%s, %ad)' --date=short + + # Show who contributed with summarized changes + who = shortlog --summary -- + + # Show who contributed, in descending order by number of commits + whorank = shortlog --summary --numbered --no-merges + + # List all issues mentioned in commit messages between range of commits + # + # Replace `\\\"ISSUE-[0-9]\\+\\\"` regular expression with one matching your issue tracking system. + # For Jira it should be as simple as putting your project name in place of `ISSUE`. + # + # Best used with tags: + # $ git issues v1.0..v1.1 + # + # But will work with any valid commit range: + # $ git issues master..HEAD + + issues = !sh -c \"git log $1 --oneline | grep -o \\\"ISSUE-[0-9]\\+\\\" | sort -u\" + + # Show the commit's parents + commit-parents = !"f(){ git cat-file -p \"${*:-HEAD}\" | sed -n '/0/,/^ *$/{/^parent /p}'; };f" + + # Is the commit a merge commit? If yes exit 0, else exit 1 + commit-is-merge = !"f(){ [ -n \"$(git commit-parents \"$*\" | sed '0,/^parent /d')\" ];};f" + + # Show the commit's keyword-marked lines. + # + # Show each line in the commit message that starts with zero or more blanks, + # then a keyword (alphanum and dash characters), then a colon. + # + # Example commit: + # + # commit ce505d161fccdbc8d4bf12047846de7433ad6d04 + # Author: Joel Parker Henderson + # Date: Tue May 28 11:53:47 2019 -0700 + # + # Add feature foo + # + # This commit is to add feature foo. + # + # Time: 5 hours + # Cost: 600 USD + # + # Command: + # + # $ git commit-message-key-lines ce505d161fccdbc8d4bf12047846de7433ad6d04 + # Commit: ce505d161fccdbc8d4bf12047846de7433ad6d04 + # Author: Joel Parker Henderson + # Date: Tue May 28 11:53:47 2019 -0700 + # Time: 5 hours + # Cost: 600 USD + # + # Normalize the output: + # + # * Start the output with "Commit: " + # + # * Omit leading blanks + # + # * After the colon, use one space (not tab, not multiple spaces, etc.) + # + # Known issues: + # + # * TODO: improve the keyword matcher so it requires the keyword to end + # in an alphanum (not a dash), and also so the dash is a separator i.e. + # the matcher does not accept a dash followed by another dash. + # + commit-message-key-lines = "!f(){ echo \"Commit: $1\"; git log \"$1\" --format=fuller | grep \"^[[:blank:]]*[[:alnum:]][-[:alnum:]]*:\" | sed \"s/^[[:blank:]]*//; s/:[[:blank:]]*/: /\"; }; f" + + + ### WORKFLOW ALIASES ### + + # Clone a git repository including all submodules + cloner = clone --recursive + + # Clone as lean as possible, for example to checkout just one subdiretory. + # + # This skips fetching unneeded objects from the server. + # + # Command breakdown: + # + # * --depth 1 does a shallow clone and implies --single-branches + # + # * --filter=blob:none skips all blobs, but fetches all tree objects + # + # * --filter=tree:0 skips unneeded trees + # + # * --filter=combine:FILTER1+FILTER2 is the syntax to use multiple + # filters at once; trying to pass --filter multiple times fails + # with: "multiple filter-specs cannot be combined". + # + # This uses --filter=tree:0 added in Git 2.20 and --filter=combine + # composite filter added in Git 2.24. + # + # The server should be configured with: + # + # git config --local uploadpack.allowfilter 1 + # git config --local uploadpack.allowanysha1inwant 1 + # + # An extension was made to the Git remote protocol to support this + # feature in v2.19.0 and actually skip fetching unneeded objects. + # There was server support then, but it can be locally tested. + # + # Credit: https://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of-a-git-repository/52269934#52269934 + # + clone-lean = clone --depth 1 --filter=combine:blob:none+tree:0 --no-checkout + + # Stash aliases for push & pop + # + # Note that if you are using an older version of git, before 2.16.0, + # then you can use the older "stash save" instead of the newer "stash push". + save = stash push + pop = stash pop + + # Stash snapshot - from http://blog.apiaxle.com/post/handy-git-tips-to-stop-you-getting-fired/ + # Take a snapshot of your current working tree without removing changes. + # This is handy for refactoring where you can't quite fit what you've done + # into a commit but daren't stray too far from now without a backup. + # + # Running this: + # + # $ git snapshot + # + # Creates this stash: + # + # stash@{0}: On feature/handy-git-tricks: snapshot: Mon Apr 8 12:39:06 BST 2013 + # + # And seemingly no changes to your working tree. + # + snapshot = !git stash push --include-untracked --message \"snapshot: $(date)\" && git stash apply \"stash@{0}\" + + # When you're a little worried that the world is coming to an end + panic = !tar cvf ../panic.tar * + + # Create an archive file of everything in the repo + archive = !"f() { top=$(rev-parse --show-toplevel); cd $top; tar cvf $top.tar $top ; }; f" + + # Do everything we can to synchronize all changes for the current branch. + # + # * git get: fetch and prune, pull and rebase, then update submodules + # * git put: commit all items, then push + # + # If you want to preserve merges, then we recommend you set this: + # + # git config pull.rebase preserve + # + # TODO: handle tags, delete superfluous branches, and add error handing. + # + get = !git fetch --prune && git pull --rebase && git submodule update --init --recursive + put = !git commit --all && git push + + # Do everything we can to make the local repo like the master branch. + # + # TODO: handle tags, and delete superfluous branches, and add error handling. + # + mastery = !git checkout master && git fetch origin --prune && git reset --hard origin/master + + # Ignore all untracked files by appending them to .gitignore: + ignore = "!git status | grep -P \"^\\t\" | grep -vF .gitignore | sed \"s/^\\t//\" >> .gitignore" + + # Do a push/pull for just one branch + push1 = "!git push origin $(git branch-name)" + pull1 = "!git pull origin $(git branch-name)" + + # Track and untrack, with default parameters, and with printing the command + track = "!f(){ branch=$(git rev-parse --abbrev-ref HEAD); cmd=\"git branch $branch -u ${1:-origin}/${2:-$branch}\"; echo $cmd; $cmd; }; f" + untrack = "!f(){ branch=$(git rev-parse --abbrev-ref HEAD); cmd=\"git branch --unset-upstream ${1:-$branch}\"; echo $cmd; $cmd; }; f" + + # Track all remote branches that aren't already being tracked; + # this is a bit hacky because of the parsing, and we welcome + # better code that works using more-specific git commands. + track-all-remote-branches = !"f() { git branch -r | grep -v ' -> ' | sed 's/^ \\+origin\\///' ; }; f" + + ## + # Reset & Undo + ## + + # Reset and undo aliases are ways to move backwards on the commit chain. + # We find that novices prefer the wording "undo"; experts prefer "reset". + reset-commit = reset --soft HEAD~1 + reset-commit-hard = reset --hard HEAD~1 + reset-commit-clean = !git reset --hard HEAD~1 && git clean -fd + reset-to-pristine = !git reset --hard && git clean -ffdx + reset-to-upstream = !git reset --hard $(git upstream-name) + + # Undo is simply a synonym for "reset" because "undo" can help novices. + undo-commit = reset --soft HEAD~1 + undo-commit-hard = reset --hard HEAD~1 + undo-commit-clean = !git reset --hard HEAD~1 && git clean -fd + undo-to-pristine = !git reset --hard && git clean -ffdx + undo-to-upstream = !git reset --hard $(git upstream-name) + + # Nicknames + uncommit = reset --soft HEAD~1 + unadd = reset HEAD + unstage = reset HEAD + + # Discard changes in a (list of) file(s) in working tree + discard = checkout -- + + # Clean and discard changes and untracked files in working tree + cleanout = !git clean -df && git checkout -- . + + # Expunge a file everywhere; this command is typically for a serious problem, + # such as accidentally committing a file of sensitive data, such as passwords. + # After you use command, you will likely need to force push everything. + # See https://help.github.com/articles/removing-sensitive-data-from-a-repository/ + expunge = !"f() { git filter-branch --force --index-filter \"git rm --cached --ignore-unmatch $1\" --prune-empty --tag-name-filter cat -- --all }; f" + + # Edit all files of the given type + edit-cached = !"f() { git ls-files --cached | sort -u ; }; `git var GIT_EDITOR` `f`" + edit-deleted = !"f() { git ls-files --deleted | sort -u ; }; `git var GIT_EDITOR` `f`" + edit-others = !"f() { git ls-files --others | sort -u ; }; `git var GIT_EDITOR` `f`" + edit-ignored = !"f() { git ls-files --ignored | sort -u ; }; `git var GIT_EDITOR` `f`" + edit-killed = !"f() { git ls-files --killed | sort -u ; }; `git var GIT_EDITOR` `f`" + edit-modified = !"f() { git ls-files --modified | sort -u ; }; `git var GIT_EDITOR` `f`" + edit-stage = !"f() { git ls-files --stage | cut -f2 | sort -u ; }; `git var GIT_EDITOR` `f`" + + # Editing and adding conflicted files: when we get many merge conflicts + # and want to quickly solve them using an editor, then add the files. + edit-unmerged = !"f() { git ls-files --unmerged | cut -f2 | sort -u ; }; `git var GIT_EDITOR` `f`" + add-unmerged = !"f() { git ls-files --unmerged | cut -f2 | sort -u ; }; git add `f`" + + # Ours & Theirs - easy merging when you know which files you want + # + # Sometimes during a merge you want to take a file from one side wholesale. + # + # The following aliases expose the ours and theirs commands which let you + # pick a file(s) from the current branch or the merged branch respectively. + # + # * ours: checkout our version of a file and add it + # * theirs: checkout their version of a file and add it + # + # N.b. the function is there as hack to get $@ doing + # what you would expect it to as a shell user. + # + ours = !"f() { git checkout --ours $@ && git add $@; }; f" + theirs = !"f() { git checkout --theirs $@ && git add $@; }; f" + + # Work In Progress: from https://gist.github.com/492227 and VonC on stackoverflow. + # This enables a quick way to add all new and modified files to the index, + # while cleaning the index from the files removed from the working tree; + # this cleaning will facilitate a rebase, because there won't be any conflict + # due to an "unclean" working directory (not in sync with the index). + # The unwip will restore the deleted files to the working tree. + wip = !"git add --all; git ls-files --deleted -z | xargs -0 git rm; git commit --message=wip" + unwip = !"git log -n 1 | grep -q -c wip && git reset HEAD~1" + + # Assume + # + # Sometimes we want to change a file in a repo, but never check in your edits. + # We can't use .gitignore because the file is tracked. We use update-index. + # + # If you interact with big corporate projects, such as projects in Subversion, + # then you might run into the need to ignore certain files which are under + # Subversion control, yet you need to modify them but not commit. + # The assume-unchanged flag comes to the rescue. + # + # Suppose we want to edit passwords.txt and for god's sake never check it in: + # + # $ git status + # modified passwords.txt + # modified foo.txt + # + # $ git assume passwords.txt + # $ git status + # modified foo.txt + # + # $ git assumed + # passwords.txt + # + # $ git unassume passwords.txt + # $ git status + # modified passwords.txt + # modified foo.txt + # + # Thanks to http://durdn.com/blog/2012/11/22/must-have-git-aliases-advanced-examples/ + # Thanks to http://blog.apiaxle.com/post/handy-git-tips-to-stop-you-getting-fired/ + + assume = update-index --assume-unchanged + unassume = update-index --no-assume-unchanged + assume-all = "!git st -s | awk {'print $2'} | xargs git assume" + unassume-all = "!git assumed | xargs git update-index --no-assume-unchanged" + assumed = !"git ls-files -v | grep ^h | cut -c 3-" + + # Delete all branches that have already been merged into the master branch. + master-cleanse = !git master-cleanse-local; git master-cleanse-remote + + # Delete all local branches that have been merged into the local master branch. + master-cleanse-local = "!git checkout master && git branch --merged | xargs git branch --delete" + + # Delete all remote branches that have been merged into the remote master branch. + master-cleanse-remote = !"git branch --remotes --merged origin/master | sed 's# *origin/##' | grep -v '^master$' xargs -I% git push origin :% 2>&1 | grep --colour=never 'deleted'" + + # Publish the current branch by pushing it to the remote "origin", + # and setting the current branch to track the upstream branch. + publish = !"git push --set-upstream origin $(git branch-name)" + + # Unpublish the current branch by deleting the + # remote version of the current branch. + unpublish = !"git push origin :$(git branch-name)" + + # Delete a branch name, then create the same branch name based on master - + # useful if you have, for example, a development branch and master branch + # and they go out of sync, and you want to nuke the development branch. + # + # Calls the `publish` and `unpublish` aliases. + # + reincarnate = !"f() { [[ -n $@ ]] && git checkout \"$@\" && git unpublish && git checkout master && git branch -D \"$@\" && git checkout -b \"$@\" && git publish; }; f" + + # Friendly wording is easier to remember. + # Thanks to http://gggritso.com/human-git-aliases + branches = branch -a + tags = tag -n1 --list + stashes = stash list + + + ### SHELL SCRIPTING ALIASES ### + + # Get the top level directory name + top-name = rev-parse --show-toplevel + + # Get the current branch name + branch-name = rev-parse --abbrev-ref HEAD + + # Get the upstream branch name + upstream-name = !git for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD) + + # Execute shell scripts. Git always runs scripts in the top directory. + # For example "git exec pwd" will always show you the top directory. + exec = ! exec + + + ### MAINTENANCE ALIASES ### + + # pruner: prune everything that is unreachable now. + # + # This command takes a long time to run, perhaps even overnight. + # + # This is useful for removing unreachable objects from all places. + # + # By [CodeGnome](http://www.codegnome.com/) + # + pruner = !"git prune --expire=now; git reflog expire --expire-unreachable=now --rewrite --all" + + # repacker: repack a repo the way Linus recommends. + # + # This command takes a long time to run, perhaps even overnight. + # + # It does the equivalent of "git gc --aggressive" + # but done *properly*, which is to do something like: + # + # git repack -a -d --depth=250 --window=250 + # + # The depth setting is about how deep the delta chains can be; + # make them longer for old history - it's worth the space overhead. + # + # The window setting is about how big an object window we want + # each delta candidate to scan. + # + # And here, you might well want to add the "-f" flag (which is + # the "drop all old deltas", since you now are actually trying + # to make sure that this one actually finds good candidates. + # + # And then it's going to take forever and a day (ie a "do it overnight" + # thing). But the end result is that everybody downstream from that + # repository will get much better packs, without having to spend any effort + # on it themselves. + # + # http://metalinguist.wordpress.com/2007/12/06/the-woes-of-git-gc-aggressive-and-how-git-deltas-work/ + # + # We also add the --window-memory limit of 1 gig, which helps protect + # us from a window that has very large objects such as binary blobs. + # + repacker = repack -a -d -f --depth=300 --window=300 --window-memory=1g + + # Do everything we can to optimize the repository. + # + # This command takes a long time to run, perhaps even overnight. + # + # Currently, this command simply calls `git pruner` and `git repacker`. + # There's a step that may be unnecessarying, calling `git prune-pack`. + # + optimize = !git pruner; git repacker; git prune-packed + + + ### ADVANCED ALIASES ### + + # Search for a given string in all patches and print commit messages. + # Posted by Mikko Rantalainen on StackOverflow. + # + # Example: search for any commit that adds or removes string "foobar" + # git searchcommits foobar + # + # Example: search commits for string "foobar" in directory src/lib + # git searchcommits foobar src/lib + # + # Example: search commits for "foobar", print full diff of commit with 1 line context + # git searchcommits foobar --pickaxe-all -U1 src/lib + searchcommits = !"f() { query=\"$1\"; shift; git log -S\"$query\" \"$@\"; }; f \"$@\"" + + # A 'debug' alias to help debugging builtins: when debugging builtins, + # we use gdb to analyze the runtime state. However, we have to disable + # the pager, and often we have to call the program with arguments. + # If the program to debug is a builtin, we use this alias. + debug = !GIT_PAGER= gdb --args git + + # Getting the diff of only one function: when we want to see just the + # differences of one function in one file in two different commits, + # we create two temp files which contain only the function, then diff. + # Use this alias this way: git funcdiff + # diff-func = !sh -c "git show \"\$1:\$3\" | sed -n \"/^[^ \t].*\$4(/,/^}/p\" > .tmp1 && git show \"\$2:\$3\" | sed -n \"/^[^ \t].*\$4(/,/^}/p\" > .tmp2 && git diff --no-index .tmp1 .tmp2" - + + # Calling "interdiff" between commits: if upstream applied a + # slightly modified patch, and we want to see the modifications, + # we use the program interdiff of the patchutils package. + intercommit = !sh -c 'git show "$1" > .git/commit1 && git show "$2" > .git/commit2 && interdiff .git/commit[12] | less -FRS' - + + # Prune all your stale remote branches: there's no way to tell + # git remote update to prune stale branches, and git remote prune + # does not understand --all. So here is a shell command to do it. + prune-all = !git remote | xargs -n 1 git remote prune + + # Thanks to cody cutrer + cherry-pick-merge = !"sh -c 'git cherry-pick --no-commit --mainline 1 $0 && \ + git log -1 --pretty=%P $0 | cut -b 42- > .git/MERGE_HEAD && \ + git commit --verbose'" + + # Thanks to jtolds on stackoverflow + remote-ref = !"sh -c ' \ + local_ref=$(git symbolic-ref HEAD); \ + local_name=${local_ref##refs/heads/}; \ + remote=$(git config branch.\"#local_name\".remote || echo origin); \ + remote_ref=$(git config branch.\"$local_name\".merge); \ + remote_name=${remote_ref##refs/heads/}; \ + echo remotes/$remote/$remote_name'" + + # Thanks to jtolds on stackoverflow + rebase-recent = !git rebase --interactive $(git remote-ref) + + # Use graphviz for display. + # This produces output that can be displayed using dotty, for example: + # $ git graphviz HEAD~100..HEAD~60 | dotty /dev/stdin + # $ git graphviz --first-parent master | dotty /dev/stdin + graphviz = !"f() { echo 'digraph git {' ; git log --pretty='format: %h -> { %p }' \"$@\" | sed 's/[0-9a-f][0-9a-f]*/\"&\"/g' ; echo '}'; }; f" + + # Serve the local directory by starting a git server daemon, so others can pull/push from my machine + serve = "-c daemon.receivepack=true daemon --base-path=. --export-all --reuseaddr --verbose" + + ########################################################################## + + ## + # Git alias settings suitable for topic branches. + # + # These aliases are simple starting points for a simple topic flow. + # Lots of people have lots of ideas about how to do various git flows. + # + # Some people like to use a topic branch for a new feature, or a + # hotfix patch, or refactoring work, or some spike research, etc. + # + # Start work on a new topic branch, which creates your branch: + # + # $ git topic-start add-feature-foo + # + # Do work, and optionally sync our changes, which pushes and pulls: + # + # $ git topic-sync + # + # Stop work on a topic branch, which deletes your branch: + # + # $ git topic-stop + # + # If you want to move your branch a.k.a. rename it: + # + # $ git topic-rename + # + # Ideas for your own alias customizations: + # + # * Notify your team, such as by sending an email, posting to chat, etc. + # + # * Trigger testing of the new topic branch to ensure all tests succeed. + # + # * Update your project management software with the new topic name. + # + # Customize these aliases as you like for your own workflow. + ## + + ## + # Provide the name of the topic base branch, such as "main". + # + # When we create a new topic branch, we base it on the topic base branch. + # Many projects use the topic base branch name "main". Some projects use + # use "trunk", "develop", "deploy", "integrate", "release", "green", etc. + # + # The topic base branch name is "main" by default. You can customize + # the name for your local repo, or your own user's global configuration, + # or your system configuration, by using `git config` such as: + # + # $ git config --local gitalias.topic.base.branch.name "foo" + # + # $ git config --global gitalias.topic.base.branch.name "foo" + # + # $ git config --system gitalias.topic.base.branch.name "foo" + # + # Thanks to https://github.com/gwjo + ## + + topic-base-branch-name = "!f(){ \ + git config --get gitalias.topic.base.branch.name || printf '%s\n' main; \ + };f" + + ## + # Start a topic branch. + # + # Example: + # + # git topic-start add-feature-foo + # + # We use this alias to begin work on a new feature, + # new task, new fix, new refactor, new optimization, etc. + # + # Customize this alias as you like for your own workflow. + # + # Our workflow does these steps: + # + # 1. Update the base branch. + # 2. Create a new branch with your topic name, based on the base branch. + # 3. Push the topic branch, so our team members can see the new branch. + # + # If you use a sharing site such a GitHub, and use typical settings, + # then this implementation makes your branch visible to collaborators. + # + # Many teams share branches before they are fully ready, to help + # the team provide feedback on the work-in-progress, and also to + # run any automatic tests to verify the branch runs successfully. + ## + + topic-start = "!f(){ \ + topic_branch=\"$1\"; \ + base_branch=$(git topic-base-branch-name); \ + git checkout \"$base_branch\"; git pull; \ + git checkout -b \"$topic_branch\" \"$base_branch\"; \ + git push --set-upstream origin \"$topic_branch\"; \ + };f" + + ## + # Stop a topic branch; this must be the current branch. + # + # Example: + # + # git topic-stop + # + # We use this alias to complete work on a new feature, + # new task, new fix, new refactor, new optimization, etc. + # + # Customize this alias as you like for your own workflow. + # + # Our workflow does these steps: + # + # 1. Push the topic branch. + # 2. Delete the topic branch locally. + # 3. Delete the topic branch remotely. + # + # If you use a sharing site such a GitHub, and use typical settings, + # then this implementation deletes your branch for the site. + # + # Many teams choose to delete topic branches when they are finished, + # to keep the repositories clean and with a smaller number of branches. + # + # If git says "unable to push to unqualified destination" then it means + # that the remote branch doesn't exist, so git is unable to delete it. + # That's fine; it means someone else has already deleted the branch. + # To synchronize your branch list, use "git fetch --prune". + ## + + topic-stop = "!f(){ \ + topic_branch=$(git branch-name); \ + base_branch=$(git topic-base-branch-name); \ + if [ \"$topic_branch\" = \"$base_branch\" ]; then \ + printf \"You are asking to do git topic-stop,\n\"; \ + printf \"but you are not currently on a topic branch;\n\"; \ + printf \"you are on the base branch: $base_branch.\n\"; \ + printf \"Please checkout the topic branch that you want,\n\"; \ + printf \"then retry the git topic delete command.\n\"; \ + else \ + git push; \ + git checkout \"$base_branch\"; \ + git branch --delete \"$topic_branch\"; \ + git push origin \":$topic_branch\"; \ + fi; \ + };f" + + ## + # Update the current topic branch by synchronizing changes. + # + # Example: + # + # git topic-sync + # + # This implementation does these: + # + # 1. Pull any changes. + # 2. Push any changes. + # + # If you use any kind of testing framework, or test driven development, + # then it can be wise to test your topic immediately after running this, + # to ensure that any available updates are successfully integrated. + # + # Customize this alias as you like for your own workflow. + ## + + topic-sync = "!f(){ \ + topic_branch=$(git branch-name); \ + base_branch=$(git topic-base-branch-name); \ + if [ \"$topic_branch\" = \"$base_branch\" ]; then \ + printf \"You are asking to do git topic-sync,\n\"; \ + printf \"but you are not currently on a topic branch;\n\"; \ + printf \"you are on the base branch: $base_branch.\n\"; \ + printf \"Please checkout the topic branch that you want,\n\"; \ + printf \"then retry the git topic delete command.\n\"; \ + else \ + git pull; \ + git push; \ + fi; \ + };f" + + ## + # Move the current topic branch, a.k.a. rename it. + # + # Example: + # + # git topic-move hello + # + # This implementation does these: + # + # 1. Move the local branch. + # 2. Move the remote branch by pushing to origin. + # + # Customize this alias as you like for your own workflow. + ## + + topic-move = "!f(){ \ + new_branch=\"$1\"; \ + old_branch=$(git branch-name); \ + git branch --move \"$old_branch\" \"$new_branch\"; \ + git push origin \":$old_branch\" \"$new_branch\"; \ + };f" + + + ########################################################################## + + ## + # Git aliases suitable for particular software integrations and tooling, + # such as other version control system e.g. CVS, Subversion, etc. + ## + + ### CVS ALIAS ### + + cvs-i = cvsimport -k -a + cvs-e = cvsexportcommit -u -p + + ### GitK ### + + # show conflicting merge in gitk: + gitk-conflict = !gitk --left-right HEAD...MERGE_HEAD + + # show full history in gitk (including "deleted" branches and stashes) + gitk-history-all = !gitk --all $( git fsck | awk '/dangling commit/ {print $3}' ) + + ### Ruby on Rails ### + + # Do everything we can to synchronize all changes for a Ruby On Rails app. + # We like using rebase (instead of merge), bundle for gems, and rake db:migrate + rails-get = !"git pull --rebase; git submodule update --init --recursive; bundle check || bundle install; bundle exec rake db:migrate; bundle exec rake db:test:prepare" + + ### Subversion ### + + svn-b = svn branch + svn-m = merge --squash + svn-c = svn dcommit + svn-cp = !GIT_EDITOR='sed -i /^git-svn-id:/d' git cherry-pick --edit + + ########################################################################## + + ## + # Git aliases to correct common typing mistakes, which git built-in autocorrection + # does not handle + ## + + ### Use with shell alias `gitp = git` ### + + ull = pull + u = push + ush = push + uhs = push + uhsup = push -u origin HEAD + ushup = push -u origin HEAD + + # GitFlow shortcuts + fid = !git flow init -d + + # "fcb" alias is a shortcut for getting current branch for GitFlow (without prefix) + # and is strictly related to [gitflow "prefix"] config section (cuts everything after first "/") + fcb = "!f() { git rev-parse --abbrev-ref HEAD | cut -d'/' -f 2-; }; f" + + cf = "!f() { git checkout $(git config --get gitflow.prefix.feature || echo feature)$1; }; f" + ffs = "!f() { if [ ! -z $1 ] ; then git flow feature start $1 ${2:-develop}; else echo 'Invalid name'; exit 1; fi; }; f" + fff = !git flow feature finish -F $(git fcb) + ffp = !git flow feature publish $(git fcb) + + cb = "!f() { git checkout $(git config --get gitflow.prefix.bugfix || echo bugfix)$1; }; f" + fbs = "!f() { if [ ! -z $1 ] ; then git flow bugfix start $1 ${2:-develop}; else echo 'Invalid name'; exit 1; fi; }; f" + fbf = !git flow bugfix finish -F $(git fcb) + fbp = !git flow bugfix publish $(git fcb) + + ch = "!f() { git checkout $(git config --get gitflow.prefix.hotfix || echo hotfix)$1; }; f" + fhs = "!f() { if [ ! -z $1 ] ; then git flow hotfix start $1 ${2:-master}; else echo 'Invalid name'; exit 1; fi; }; f" + fhf = "!git fetch --tags; git pull $(git config --get gitflow.origin || echo origin) master; git flow hotfix finish -F $(git fcb)" + fhp = !git flow hotfix publish $(git fcb) + + cr = "!f() { git checkout $(git config --get gitflow.prefix.release || echo release)$1; }; f" + frs = "!f() { if [ ! -z $1 ] ; then git flow release start $1 ${2:-master}; else echo 'Invalid name'; exit 1; fi; }; f" + frf = !git flow release finish -F $(git fcb) + frp = !git flow release publish $(git fcb) + # rms = restore --staged + rms = "!f() { git reset HEAD -- $1; }; f" + + rs = restore --staged + remove-tags = "!f() { git tag -l ${1} | xargs -I % echo \"git tag -d % && git push --delete origin %\" | sh; }; f" + + sr = "!f() { \ + current_branch=$(git rev-parse --abbrev-ref HEAD); \ + git stash save -u 'Stash for switch-rebase' && \ + git checkout $1 && \ + git pull origin $1 && \ + git checkout $current_branch && \ + git rebase $1 && \ + git stash pop; \ + }; f" diff --git a/gnupg/.gnupg/gpg-agent.conf b/gnupg/.gnupg/gpg-agent.conf new file mode 100644 index 0000000..5b175a9 --- /dev/null +++ b/gnupg/.gnupg/gpg-agent.conf @@ -0,0 +1,2 @@ +enable-ssh-support +pinentry-program /usr/bin/pinentry-gtk diff --git a/gnupg/.gnupg/sshcontrol b/gnupg/.gnupg/sshcontrol new file mode 100644 index 0000000..9e1fd8c --- /dev/null +++ b/gnupg/.gnupg/sshcontrol @@ -0,0 +1,12 @@ +# RSA key added on: 2023-01-29 18:51:54 +# Fingerprints: MD5:28:61:8b:e9:f0:23:22:b3:e5:b5:5d:5a:65:af:e5:71 +# SHA256:0xEvNdCNsAG2J82KtwLOem4cmh/Akj/ozM+CXVDgF60 +BA5799350656B2D67BEB495BA25443309786AAE2 # marianoz +# Ed25519 key added on: 2023-09-07 20:01:58 +# Fingerprints: MD5:68:36:28:df:3e:a3:9e:b0:ec:da:d4:27:99:d2:60:ac +# SHA256:UBykD9jRWIRwypoVfyNjJ400aMCsaAURO+P+H/cdDtk +9E562177767C07DA6E5E1CF7628CC0BE8C67C1CB 0 +# Ed25519 key added on: 2023-09-10 15:26:23 +# Fingerprints: MD5:62:10:c9:13:21:90:1d:1b:5f:33:38:89:20:e8:be:5a +# SHA256:oL1/LJZ8RHKcluZQgy8cvitg3nLSe+A9Hw6xGPVCcdA +6CBE903E52E84CEDBA3A2CCCCBB2EDAE537F4355 0 diff --git a/kitty/.config/kitty/kitty.conf b/kitty/.config/kitty/kitty.conf new file mode 100644 index 0000000..f990850 --- /dev/null +++ b/kitty/.config/kitty/kitty.conf @@ -0,0 +1,64 @@ +# Font settings +font_family JetBrains Mono +# font_family Fira Code +# font_family Iosevka\ Nerd\ Font +# font_family MonoLisa +# font_family Proxima\ Nova +# font_family Source\ Code\ Pro +font_size 12.0 +bold_font auto +italic_font auto +bold_italic_font auto +font_size 12.0 + +text_composition_strategy legacy + +# cursor customization +# block / beam / underline +cursor_shape block +cursor_blink_interval 0 +cursor_stop_blinking_after 0 +shell_integration no-cursor + +# Window settings +remember_window_size no +initial_window_width 1200 +initial_window_height 750 +window_border_width 1.5pt +enabled_layouts tall +window_padding_width 0 +window_margin_width 2 +hide_window_decorations no + +background_opacity 0.90 +background_blur 1 + +# advance +term xterm-kitty + +# Tab bar +tab_bar_edge bottom +tab_bar_style hidden + +# Color scheme (you'll need to define these colors) +# include your_theme.conf +# include ./themes/rose-pine.conf +# include ./themes/Duskfox.conf +include ./themes/Nightfox.conf + +# Disable confirmation on window close +confirm_os_window_close 0 + +# Hyperlink settings +detect_urls yes +url_style curly + +# Mouse settings +mouse_hide_wait 3.0 +focus_follows_mouse no + +# ZEN MODE (font size adjustment) +map ctrl+shift+plus change_font_size all +1.0 +map ctrl+shift+minus change_font_size all -1.0 +map ctrl+shift+0 change_font_size all 0 +map ctrl+shift+r load_config_file diff --git a/kitty/.config/kitty/themes/Duskfox.conf b/kitty/.config/kitty/themes/Duskfox.conf new file mode 100644 index 0000000..a133189 --- /dev/null +++ b/kitty/.config/kitty/themes/Duskfox.conf @@ -0,0 +1,103 @@ +# vim:ft=kitty +## name: Duskfox +## author: EdenEast +## license: MIT +## upstream: https://github.com/EdenEast/nightfox.nvim/blob/main/extra/duskfox/kitty.conf +## blurb: Duskfox theme from the neovim colorscheme nightfox.nvim. + +#: All the settings below are colors, which you can choose to modify, or use the +#: defaults. You can also add non-color based settings if needed but note that +#: these will not work with using kitty @ set-colors with this theme. For a +#: reference on what these settings do see https://sw.kovidgoyal.net/kitty/conf/ + +#: The basic colors + +foreground #e0def4 +background #232136 +selection_foreground #e0def4 +selection_background #433c59 + + +#: Cursor colors + +cursor #e0def4 +cursor_text_color #232136 + + +#: URL underline color when hovering with mouse + +url_color #a3be8c + + +#: kitty window border colors and terminal bell colors + +active_border_color #569fba +inactive_border_color #4b4673 +bell_border_color #ea9a97 +# visual_bell_color none + + +#: OS Window titlebar colors + +# wayland_titlebar_color system +# macos_titlebar_color system + + +#: Tab bar colors + +active_tab_foreground #191726 +active_tab_background #569fba +inactive_tab_foreground #817c9c +inactive_tab_background #433c59 +# tab_bar_background none +# tab_bar_margin_color none + + +#: Colors for marks (marked text in the terminal) + +# mark1_foreground black +# mark1_background #98d3cb +# mark2_foreground black +# mark2_background #f2dcd3 +# mark3_foreground black +# mark3_background #f274bc + + +#: The basic 16 colors + +#: black +color0 #393552 +color8 #47407d + +#: red +color1 #eb6f92 +color9 #f083a2 + +#: green +color2 #a3be8c +color10 #b1d196 + +#: yellow +color3 #f6c177 +color11 #f9cb8c + +#: blue +color4 #569fba +color12 #65b1cd + +#: magenta +color5 #c4a7e7 +color13 #ccb1ed + +#: cyan +color6 #9ccfd8 +color14 #a6dae3 + +#: white +color7 #e0def4 +color15 #e2e0f7 + +#: You can set the remaining 240 colors as color16 to color255. + +color16 #ea9a97 +color17 #eb98c3 diff --git a/kitty/.config/kitty/themes/Nightfox.conf b/kitty/.config/kitty/themes/Nightfox.conf new file mode 100644 index 0000000..6e9772d --- /dev/null +++ b/kitty/.config/kitty/themes/Nightfox.conf @@ -0,0 +1,52 @@ +# vim:ft=kitty + +## name: Nightfox +## author: EdenEast +## license: MIT +## upstream: https://github.com/EdenEast/nightfox.nvim/blob/main/extra/nightfox/nightfox_kitty.conf + +background #192330 +foreground #cdcecf +selection_background #2b3b51 +selection_foreground #cdcecf +url_color #81b29a + +# Cursor +# uncomment for reverse background +# cursor none +cursor #cdcecf + +# Border +active_border_color #719cd6 +inactive_border_color #39506d +bell_border_color #f4a261 + +# Tabs +active_tab_background #719cd6 +active_tab_foreground #131a24 +inactive_tab_background #2b3b51 +inactive_tab_foreground #738091 + +# normal +color0 #393b44 +color1 #c94f6d +color2 #81b29a +color3 #dbc074 +color4 #719cd6 +color5 #9d79d6 +color6 #63cdcf +color7 #dfdfe0 + +# bright +color8 #575860 +color9 #d16983 +color10 #8ebaa4 +color11 #e0c989 +color12 #86abdc +color13 #baa1e2 +color14 #7ad5d6 +color15 #e4e4e5 + +# extended colors +color16 #f4a261 +color17 #d67ad2 diff --git a/kitty/.config/kitty/themes/rose-pine-dawn.conf b/kitty/.config/kitty/themes/rose-pine-dawn.conf new file mode 100644 index 0000000..397c9a8 --- /dev/null +++ b/kitty/.config/kitty/themes/rose-pine-dawn.conf @@ -0,0 +1,56 @@ +## name: RosΓ© Pine Dawn +## author: mvllow +## license: MIT +## upstream: https://github.com/rose-pine/kitty/blob/main/dist/rose-pine-dawn.conf +## blurb: All natural pine, faux fur and a bit of soho vibes for the classy minimalist + +foreground #575279 +background #faf4ed +selection_foreground #575279 +selection_background #dfdad9 + +cursor #cecacd +cursor_text_color #575279 + +url_color #907aa9 + +active_tab_foreground #575279 +active_tab_background #f2e9e1 +inactive_tab_foreground #9893a5 +inactive_tab_background #faf4ed + +active_border_color #286983 +inactive_border_color #dfdad9 + +# black +color0 #f2e9e1 +color8 #9893a5 + +# red +color1 #b4637a +color9 #b4637a + +# green +color2 #286983 +color10 #286983 + +# yellow +color3 #ea9d34 +color11 #ea9d34 + +# blue +color4 #56949f +color12 #56949f + +# magenta +color5 #907aa9 +color13 #907aa9 + +# cyan +color6 #d7827e +color14 #d7827e + +# white +color7 #575279 +color15 #575279 + diff --git a/kitty/.config/kitty/themes/rose-pine-moon.conf b/kitty/.config/kitty/themes/rose-pine-moon.conf new file mode 100644 index 0000000..4d4de88 --- /dev/null +++ b/kitty/.config/kitty/themes/rose-pine-moon.conf @@ -0,0 +1,56 @@ +## name: RosΓ© Pine Moon +## author: mvllow +## license: MIT +## upstream: https://github.com/rose-pine/kitty/blob/main/dist/rose-pine-moon.conf +## blurb: All natural pine, faux fur and a bit of soho vibes for the classy minimalist + +foreground #e0def4 +background #232136 +selection_foreground #e0def4 +selection_background #44415a + +cursor #56526e +cursor_text_color #e0def4 + +url_color #c4a7e7 + +active_tab_foreground #e0def4 +active_tab_background #393552 +inactive_tab_foreground #6e6a86 +inactive_tab_background #232136 + +active_border_color #3e8fb0 +inactive_border_color #44415a + +# black +color0 #393552 +color8 #6e6a86 + +# red +color1 #eb6f92 +color9 #eb6f92 + +# green +color2 #3e8fb0 +color10 #3e8fb0 + +# yellow +color3 #f6c177 +color11 #f6c177 + +# blue +color4 #9ccfd8 +color12 #9ccfd8 + +# magenta +color5 #c4a7e7 +color13 #c4a7e7 + +# cyan +color6 #ea9a97 +color14 #ea9a97 + +# white +color7 #e0def4 +color15 #e0def4 + diff --git a/kitty/.config/kitty/themes/rose-pine.conf b/kitty/.config/kitty/themes/rose-pine.conf new file mode 100644 index 0000000..575c06b --- /dev/null +++ b/kitty/.config/kitty/themes/rose-pine.conf @@ -0,0 +1,56 @@ +## name: RosΓ© Pine +## author: mvllow +## license: MIT +## upstream: https://github.com/rose-pine/kitty/blob/main/dist/rose-pine.conf +## blurb: All natural pine, faux fur and a bit of soho vibes for the classy minimalist + +foreground #e0def4 +background #191724 +selection_foreground #e0def4 +selection_background #403d52 + +cursor #524f67 +cursor_text_color #e0def4 + +url_color #c4a7e7 + +active_tab_foreground #e0def4 +active_tab_background #26233a +inactive_tab_foreground #6e6a86 +inactive_tab_background #191724 + +active_border_color #31748f +inactive_border_color #403d52 + +# black +color0 #26233a +color8 #6e6a86 + +# red +color1 #eb6f92 +color9 #eb6f92 + +# green +color2 #31748f +color10 #31748f + +# yellow +color3 #f6c177 +color11 #f6c177 + +# blue +color4 #9ccfd8 +color12 #9ccfd8 + +# magenta +color5 #c4a7e7 +color13 #c4a7e7 + +# cyan +color6 #ebbcba +color14 #ebbcba + +# white +color7 #e0def4 +color15 #e0def4 + diff --git a/local-bin/.local/bin/betterlockscreen b/local-bin/.local/bin/betterlockscreen new file mode 100755 index 0000000..0b92ad9 --- /dev/null +++ b/local-bin/.local/bin/betterlockscreen @@ -0,0 +1,942 @@ +#!/usr/bin/env bash + +# Author : Copyright (c) 2017-2023 Pavan Jadhaw, and others (https://github.com/betterlockscreen/betterlockscreen/graphs/contributors) +# Project Repository : https://github.com/betterlockscreen/betterlockscreen + +cmd_exists () { + command -v "$1" >/dev/null +} + +init_config () { + # default options + display_on=0 + span_image=false + lock_timeout=300 + fx_list=(dim blur dimblur pixel dimpixel color) + dim_level=40 + blur_level=1 + pixel_scale=10,1000 + solid_color=333333 + description="" + quiet=false + i3lockcolor_bin="i3lock-color" + suspend_command="systemctl suspend" + convert_command="magick" + composite_command="magick composite" + + if ! cmd_exists "$i3lockcolor_bin" && cmd_exists "i3lock"; then + i3lockcolor_bin="i3lock" + fi + + if ! cmd_exists "magick"; then + convert_command="convert" + composite_command="composite" + fi + + # default theme + loginbox=00000066 + loginshadow=00000000 + locktext="Type password to unlock..." + font="sans-serif" + ringcolor=ffffffff + insidecolor=00000000 + separatorcolor=00000000 + ringvercolor=ffffffff + insidevercolor=00000000 + ringwrongcolor=ffffffff + insidewrongcolor=d23c3dff + timecolor=ffffffff + time_format="%H:%M:%S" + greetercolor=ffffffff + layoutcolor=ffffffff + keyhlcolor=d23c3dff + bshlcolor=d23c3dff + veriftext="Verifying..." + verifcolor=ffffffff + wrongtext="Failure!" + wrongcolor=d23c3dff + modifcolor=d23c3dff + bgcolor=000000ff + wallpaper_cmd="feh --bg-fill" + + # read user config + USER_CONF_DIR="${XDG_CONFIG_HOME:-$HOME/.config}" + USER_CONF="$USER_CONF_DIR/betterlockscreenrc" + SYS_CONF="/etc/betterlockscreenrc" + XDG_USER_CONF_DIR="$USER_CONF_DIR/betterlockscreen" + XDG_USER_CONF="$XDG_USER_CONF_DIR/betterlockscreenrc" + + if [ -e "$SYS_CONF" ]; then + # shellcheck source=/dev/null + source "$SYS_CONF" + fi + + if [ -e "$USER_CONF" ]; then + echof error "Please, migrate your config $USER_CONF to $XDG_USER_CONF. Old location will soon be deprecated." + echof info "mkdir -p ~/.config/betterlockscreen/ && mv $USER_CONF $XDG_USER_CONF" + + # shellcheck source=/dev/null + source "$USER_CONF" + fi + + if [ -e "$XDG_USER_CONF" ]; then + # shellcheck source=/dev/null + source "$XDG_USER_CONF" + fi + + if ! cmd_exists "$i3lockcolor_bin"; then + echof error "Unable to find i3lock-color binary under detected/configured name: '$i3lockcolor_bin'!" + exit + fi + + # Please make sure to adjust this before release! + VERSION="4.3.0" + + # paths + CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/betterlockscreen" + CUR_DIR="$CACHE_DIR/current" + + # wallpaper + CUR_W_RESIZE="$CUR_DIR/wall_resize.png" + CUR_W_DIM="$CUR_DIR/wall_dim.png" + CUR_W_BLUR="$CUR_DIR/wall_blur.png" + CUR_W_DIMBLUR="$CUR_DIR/wall_dimblur.png" + CUR_W_PIXEL="$CUR_DIR/wall_pixel.png" + CUR_W_DIMPIXEL="$CUR_DIR/wall_dimpixel.png" + CUR_W_COLOR="$CUR_DIR/wall_color.png" + + # lockscreen + CUR_L_RESIZE="$CUR_DIR/lock_resize.png" + CUR_L_DIM="$CUR_DIR/lock_dim.png" + CUR_L_BLUR="$CUR_DIR/lock_blur.png" + CUR_L_DIMBLUR="$CUR_DIR/lock_dimblur.png" + CUR_L_PIXEL="$CUR_DIR/lock_pixel.png" + CUR_L_DIMPIXEL="$CUR_DIR/lock_dimpixel.png" + CUR_L_COLOR="$CUR_DIR/lock_color.png" + + # Original DPMS timeout + DEFAULT_TIMEOUT=$(cut -d ' ' -f4 <<< "$(xset q | sed -n '25p')") + # Original DPMS status + DEFAULT_DPMS=$(xset q | awk '/^[[:blank:]]*DPMS is/ {print $(NF)}') + + # Dunst + DUNST_INSTALLED=false && [[ -e "$(command -v dunstctl)" ]] && DUNST_INSTALLED=true + DUNST_IS_RUNNING=false && [[ "$DUNST_INSTALLED" == "true" ]] && [[ "$(pgrep -c dunst)" -gt 0 ]] && DUNST_IS_RUNNING=true + DUNST_IS_PAUSED=false && [[ "$DUNST_IS_RUNNING" == "true" ]] && DUNST_IS_PAUSED=$(dunstctl is-paused) + + # Feh + FEH_INSTALLED=false && [[ -e "$(command -v feh)" ]] && FEH_INSTALLED=true +} + +# called before screen is locked +prelock() { + # set dpms timeout + if [ "$DEFAULT_DPMS" == "Enabled" ]; then + xset dpms "$lock_timeout" + fi + + # If dusnt is already paused don't pause it again + if [[ "$DUNST_IS_RUNNING" == "true" && "$DUNST_IS_PAUSED" == "false" ]]; then + dunstctl set-paused true + fi + + if [ -e "$XDG_USER_CONF_DIR/custom-pre.sh" ]; then + # shellcheck source=/dev/null + source "$XDG_USER_CONF_DIR/custom-pre.sh" + fi +} + +# lock screen with specified image +lock() { + local image="$1" + local fontlg=32 + local fontmd=16 + local fontsm=12 + + if [ -f "$image" ]; then + echof act "Locking screen..." + else + echof act "Locking screen... (FAILSAFE MODE)" + fi + + $i3lockcolor_bin \ + ${image:+-i "$image"} \ + --color "$bgcolor" \ + ${display_on:+-S "$display_on"} \ + --ind-pos="x+310:y+h-80" \ + --radius=25 \ + --ring-width=5 \ + --inside-color="$insidecolor" \ + --ring-color="$ringcolor" \ + --separator-color=$separatorcolor \ + --insidever-color="$insidevercolor" \ + --insidewrong-color="$insidewrongcolor" \ + --ringver-color="$ringvercolor" \ + --ringwrong-color="$ringwrongcolor" \ + --line-uses-inside \ + --keyhl-color="$keyhlcolor" \ + --bshl-color="$bshlcolor" \ + --clock --force-clock \ + --time-pos="ix-265:iy-10" \ + --time-align 1 \ + --time-str "$time_format" \ + --time-color="$timecolor" \ + --time-font="$font" \ + --time-size="$fontlg" \ + --date-str "" \ + --greeter-pos="ix-265:iy+12" \ + --greeter-align 1 \ + --greeter-text "$locktext" \ + --greeter-color="$greetercolor" \ + --greeter-font="$font" \ + --greeter-size="$fontmd" \ + --layout-pos="ix-265:iy+32" \ + --layout-align 1 \ + --layout-color="$layoutcolor" \ + --layout-font="$font" \ + --layout-size="$fontsm" \ + --verif-pos="ix+35:iy-34" \ + --verif-align 2 \ + --verif-text="$veriftext" \ + --verif-color="$verifcolor" \ + --verif-font="$font" \ + --verif-size="$fontsm" \ + --wrong-pos="ix+24:iy-34" \ + --wrong-align 2 \ + --wrong-text="$wrongtext" \ + --wrong-color="$wrongcolor" \ + --wrong-font="$font" \ + --wrong-size="$fontsm" \ + --modif-pos="ix+45:iy+43" \ + --modif-align 2 \ + --modif-size="$fontsm" \ + --modif-color="$modifcolor" \ + --noinput-text="" \ + --pass-media-keys \ + --pass-screen-keys \ + --pass-volume-keys \ + --pass-power-keys \ + "${lockargs[@]}" +} + +# called after screen is unlocked +postlock() { + # restore default dpms timeout + if [ "$DEFAULT_DPMS" == "Enabled" ]; then + xset dpms "$DEFAULT_TIMEOUT" + fi + + # If dunst already paused before locking don't unpause dunst + if [[ "$DUNST_IS_RUNNING" == "true" && "$DUNST_IS_PAUSED" == "false" ]]; then + dunstctl set-paused false + fi + + if [ -e "$XDG_USER_CONF_DIR/custom-post.sh" ]; then + # shellcheck source=/dev/null + source "$XDG_USER_CONF_DIR/custom-post.sh" + fi +} + +# select effect and lock screen +lockinit() { + if pgrep -u "$USER" "$i3lockcolor_bin"; then + echof error "i3lock already running" + exit 1 + fi + + echof act "Running prelock..." + prelock + + if [[ $runsuspend ]]; then + lockselect "$@" & + $suspend_command + wait $! + else + lockselect "$@" + fi + + echof act "Running postlock..." + postlock +} + +lockselect() { + case "$1" in + dim) lock "$CUR_L_DIM" ;; + blur) lock "$CUR_L_BLUR" ;; + dimblur) lock "$CUR_L_DIMBLUR" ;; + pixel) lock "$CUR_L_PIXEL" ;; + dimpixel) lock "$CUR_L_DIMPIXEL" ;; + color) lock "$CUR_L_COLOR" ;; + *) lock "$CUR_L_RESIZE" ;; + esac +} + +# calculate adjustments for hidpi displays +logical_px() { + # $1: number of pixels to convert + # $2: 1 for width. 2 for height + local pixels="$1" + local direction="$2" + local dpi + + # use DPI set by user in .Xresources + dpi=$(xrdb -q | grep -oP '^\s*Xft.dpi:\s*\K\d+' | bc) + + # or get dpi value from xdpyinfo + if [ -z "$dpi" ]; then + dpi=$(xdpyinfo | sed -En "s/\s*resolution:\s*([0-9]*)x([0-9]*)\s.*/\\$direction/p" | head -n1) + fi + + # adjust scaling + if [ -n "$dpi" ]; then + local scale + scale=$(echo "scale=3; $dpi / 96.0" | bc) + echo "$scale * $pixels / 1" | bc + else + # return the default value if no DPI is set + echo "$pixels" + fi +} + +# get total resolution, sets $TOTAL_SIZE +get_total_size () { + TOTAL_SIZE=$(xdpyinfo | grep -w "dimensions" | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/') +} + +# get list of displays, sets $DISPLAY_LIST +get_display_list () { + local count=0 + mapfile -t displays < <(xrandr --listactivemonitors) + for display in "${displays[@]:1}"; do + ((count++)) + display="$(echo "$display" | sed -r 's/\/[0-9]*//g')" + IFS=' ' read -r -a info <<< "$display" + DISPLAY_LIST+=("$count ${info[3]} ${info[2]}") + done +} + +# populate $WALL_LIST depending on number of displays and images passed +get_wall_list() { + local paths=("$@") + declare -ga WALL_LIST + + # multiple images and spanning conflict, bail out + if [ "${#paths[@]}" -gt 1 ] && [ "$span_image" = true ]; then + echof err "Can't use --span with multiple images!" + exit 1 + fi + + # if spanning return 1 image + if [ "$span_image" = true ]; then + get_image "${paths[0]}" + + # if # paths is 1 + elif [ "${#paths[@]}" -eq 1 ]; then + for ((i=0; i<${#DISPLAY_LIST[@]}; i++)); do + # add same image to $WALL_LIST for each display + get_image "${paths[0]}" + done + + # if # of paths equals # of displays + elif [ ${#paths[@]} -eq "${#DISPLAY_LIST[@]}" ]; then + for ((i=0; i<${#DISPLAY_LIST[@]}; i++)); do + # add each image to $WALL_LIST + get_image "${paths[$i]}" + done + + # if # of paths differ from # of display, bail out + else + echof err "${#paths[@]} images provided for ${#DISPLAY_LIST[@]} displays!" + exit 1 + fi +} + +# get image path, append to $WALL_LIST +get_image() { + local path="$1" + + # we have a file + if [ -f "$path" ]; then + WALL_LIST+=("$path") + return + # we have a directory + elif [ -d "$path" ]; then + dir=("$path"/*) + rdir="${dir[RANDOM % ${#dir[@]}]}" + get_image "$rdir" # <-- calls itself + # not file or directory, bail out + else + echof err "invalid path: $path" + exit 1 + fi + +} + +# scale base image and generate effects +resize_and_render () { + local base="$1" + local path="$2" + local resolution="$3" + + # resource paths + RES_RESIZE="$path/resize.png" + RES_DIM="$path/dim.png" + RES_BLUR="$path/blur.png" + RES_DIMBLUR="$path/dimblur.png" + RES_PIXEL="$path/pixel.png" + RES_DIMPIXEL="$path/dimpixel.png" + RES_COLOR="$path/color.png" + + # resize + base_resize "$base" "$RES_RESIZE" "$resolution" + + # effects + for effect in "${fx_list[@]}"; do + case $effect in + dim) fx_dim "$RES_RESIZE" "$RES_DIM";; + blur) fx_blur "$RES_RESIZE" "$RES_BLUR" "$resolution";; + dimblur) fx_dimblur "$RES_RESIZE" "$RES_DIMBLUR" "$resolution";; + pixel) fx_pixel "$RES_RESIZE" "$RES_PIXEL";; + dimpixel) fx_dimpixel "$RES_RESIZE" "$RES_DIMPIXEL";; + color) fx_color "$RES_COLOR" "$resolution";; + esac + done + +} + +# apply resize +base_resize() { + local input="$1" + local output="$2" + local size="$3" + + echof act "Resizing base image..." + eval $convert_command "$input" \ + -resize "$size""^" \ + -gravity center \ + -extent "$size" \ + "$output" +} + +# apply dim +fx_dim() { + local input="$1" + local output="$2" + + echof act "Rendering 'dim' effect..." + eval $convert_command "$input" \ + -fill black -colorize "$dim_level"% \ + "$output" +} + +# apply blur +fx_blur() { + local input="$1" + local output="$2" + local size="$3" + + echof act "Rendering 'blur' effect..." + blur_shrink=$(echo "scale=2; 20 / $blur_level" | bc) + blur_sigma=$(echo "scale=2; 0.6 * $blur_level" | bc) + eval $convert_command "$input" \ + -filter Gaussian \ + -resize "$blur_shrink%" \ + -define "filter:sigma=$blur_sigma" \ + -resize "$size^" -gravity center -extent "$size" \ + "$output" +} + +# apply dimblur +fx_dimblur() { + local input="$1" + local output="$2" + local size="$3" + + echof act "Rendering 'dimblur' effect..." + blur_shrink=$(echo "scale=2; 20 / $blur_level" | bc) + blur_sigma=$(echo "scale=2; 0.6 * $blur_level" | bc) + eval $convert_command "$input" \ + -fill black -colorize "$dim_level"% \ + -filter Gaussian \ + -resize "$blur_shrink%" \ + -define "filter:sigma=$blur_sigma" \ + -resize "$size^" -gravity center -extent "$size" \ + "$output" +} + +# pixelate +fx_pixel() { + local input="$1" + local output="$2" + + echof act "Rendering 'pixel' effect..." + IFS=',' read -ra range <<< "$pixel_scale" + eval $convert_command "$input" \ + -scale "${range[0]}"% -scale "${range[1]}"% \ + "$output" +} + +# apply dimpixel +fx_dimpixel() { + local input="$1" + local output="$2" + + echof act "Rendering 'dimpixel' effect..." + IFS=',' read -ra range <<< "$pixel_scale" + eval $convert_command "$input" \ + -fill black -colorize "$dim_level"% \ + -scale "${range[0]}"% -scale "${range[1]}"% \ + "$output" +} + +# create solid color +fx_color() { + local output="$1" + local size="$2" + + echof act "Rendering 'color' effect..." + eval $convert_command -size "$size" canvas:\#"$solid_color" "$RES_COLOR" +} + +# create loginbox rectangle, set "$RECTANGLE" +create_loginbox () { + RECTANGLE="$CUR_DIR/rectangle.png" + local shadow="$CUR_DIR/shadow.png" + local width height + width=$(logical_px 340 1) + height=$(logical_px 100 2) + $convert_command -size "$width"x"$height" xc:\#"$loginbox" -fill none "$RECTANGLE" + $convert_command "$RECTANGLE" \ + \( -clone 0 -background \#"$loginshadow" -shadow 100x5+0+0 \) +swap \ + -background none -layers merge +repage "$shadow" + $composite_command -compose Dst_Out -gravity center \ + "$RECTANGLE" "$shadow" -alpha Set "$shadow" + $convert_command "$shadow" "$RECTANGLE" -geometry +10+10 -composite "$RECTANGLE" + [[ "$shadow" ]] && rm "$shadow" +} + +# create rectangle with description, set "$DESCRECT" +create_description () { + DESCRECT="$CUR_DIR/description.png" + local shadow="$CUR_DIR/shadow.png" + $convert_command -background none -family "$(fc-match "$font" family)" -style Normal -pointsize 14 -fill \#"$greetercolor" label:"\ $description\ " -bordercolor \#"$loginbox" -border 10 "$DESCRECT" + $convert_command "$DESCRECT" \ + \( -clone 0 -background \#"$loginshadow" -shadow 100x5+0+0 \) +swap \ + -background none -layers merge +repage "$shadow" + $composite_command -compose Dst_Out -gravity center \ + "$DESCRECT" "$shadow" -alpha Set "$shadow" + $convert_command "$shadow" "$DESCRECT" -geometry +10+10 -composite "$DESCRECT" + [[ "$shadow" ]] && rm "$shadow" +} + +# delete and recreate directory +purge_cache () { + if [[ -d "$1" ]]; then + rm -r "$1" + fi + mkdir -p "$1" +} + +# update lockscreen and wallpaper images +update () { + local images=("$@") + + echof act "Updating image cache..." + mkdir -p "$CACHE_DIR" &>/dev/null + + get_display_list # DISPLAY_LIST + get_total_size # TOTAL_SIZE + echof info "Detected ${#DISPLAY_LIST[@]} display(s) @ $TOTAL_SIZE total resolution" + + get_wall_list "${images[@]}" # WALL_LIST + echof info "Original image(s): ${WALL_LIST[*]##*/}" + + # Prepare description box to obtain width for positioning + local descwidth + local descheight + if [ -z "$description" ]; then + descwidth=0 + descheight=0 + else + create_description + descwidth=$(identify -format "%[fx:w]" "$DESCRECT") + descheight=$(identify -format "%[fx:h]" "$DESCRECT") + fi + + for ((i=0; i<${#DISPLAY_LIST[@]}; i++)); do + display="${DISPLAY_LIST[$i]}" + USER_WALL="${WALL_LIST[$i]}" + + # escape spaces for IM + if echo "$USER_WALL" | grep -E -q "[[:space:]]"; then + USER_WALL="${USER_WALL// /\\ }" + fi + + IFS=' ' read -r -a dinfo <<< "$display" + local id="${dinfo[0]}" + local device="${dinfo[1]}" + local geometry="${dinfo[2]}" + + read -r -a cols <<< "${geometry//[x+-]/ }" + local position="${geometry#*"${cols[1]}"}" + local resolution="${geometry%"${position}"*}" + + if [[ $id -eq "$display_on" ]] || [[ "$display_on" -eq 0 ]]; then + + IFS='x' read -r -a dimension <<< "$resolution" + res_x="${dimension[0]}" + res_y="${dimension[1]}" + read -r -a val <<< "${position//[+-]/ }" + read -r -a sym <<< "${position//[0-9]/ }" + pos_x="${sym[0]}${val[0]}" + pos_y="${sym[1]}${val[1]}" + + rect_x=$((pos_x + $(logical_px 15 1))) + rect_y=$((pos_y + res_y - $(logical_px 140 2))) + positions+=("+$((rect_x))+$((rect_y))") + + descrect_x=$((pos_x + res_x - descwidth - $(logical_px 15 1))) + descrect_y=$((pos_y + res_y - descheight - $(logical_px 20 2))) + positions_desc+=("+$((descrect_x))+$((descrect_y))") + fi + + local path="$CACHE_DIR/$id-$device" + purge_cache "$path" + + if [ "$span_image" = true ]; then + if [ "$id" -gt 1 ]; then + continue + else + device="[span]" + id="*" + resolution="$TOTAL_SIZE" + fi + fi + + echof info "Processing display: $device ($id)" + echof info "Resolution: $resolution" + + if [ "$span_image" = true ]; then + resize_and_render "$USER_WALL" "$path" "$resolution" + else + resize_and_render "$USER_WALL" "$path" "$resolution" + + PARAM_RESIZE="$PARAM_RESIZE $RES_RESIZE -geometry $position -composite " + PARAM_DIM="$PARAM_DIM $RES_DIM -geometry $position -composite " + PARAM_BLUR="$PARAM_BLUR $RES_BLUR -geometry $position -composite " + PARAM_DIMBLUR="$PARAM_DIMBLUR $RES_DIMBLUR -geometry $position -composite " + PARAM_PIXEL="$PARAM_PIXEL $RES_PIXEL -geometry $position -composite " + PARAM_DIMPIXEL="$PARAM_DIMPIXEL $RES_DIMPIXEL -geometry $position -composite " + PARAM_COLOR="$PARAM_COLOR $RES_COLOR -geometry $position -composite " + fi + + done + + purge_cache "$CUR_DIR" + + if [ "$span_image" = true ] || [ ${#DISPLAY_LIST[@]} -lt 2 ]; then + echof act "Rendering final wallpaper images..." + [[ -f "$RES_RESIZE" ]] && eval "cp $RES_RESIZE $CUR_W_RESIZE" + [[ -f "$RES_DIM" ]] && eval "cp $RES_DIM $CUR_W_DIM" + [[ -f "$RES_BLUR" ]] && eval "cp $RES_BLUR $CUR_W_BLUR" + [[ -f "$RES_DIMBLUR" ]] && eval "cp $RES_DIMBLUR $CUR_W_DIMBLUR" + [[ -f "$RES_PIXEL" ]] && eval "cp $RES_PIXEL $CUR_W_PIXEL" + [[ -f "$RES_DIMPIXEL" ]] && eval "cp $RES_DIMPIXEL $CUR_W_DIMPIXEL" + [[ -f "$RES_COLOR" ]] && eval "cp $RES_COLOR $CUR_W_COLOR" + else + echof act "Creating canvas: $TOTAL_SIZE" + [[ -f "$RES_RESIZE" ]] && eval "$convert_command -size $TOTAL_SIZE 'xc:blue' $CUR_W_RESIZE" + [[ -f "$RES_DIM" ]] && eval "$convert_command -size $TOTAL_SIZE 'xc:blue' $CUR_W_DIM" + [[ -f "$RES_BLUR" ]] && eval "$convert_command -size $TOTAL_SIZE 'xc:blue' $CUR_W_BLUR" + [[ -f "$RES_DIMBLUR" ]] && eval "$convert_command -size $TOTAL_SIZE 'xc:blue' $CUR_W_DIMBLUR" + [[ -f "$RES_PIXEL" ]] && eval "$convert_command -size $TOTAL_SIZE 'xc:blue' $CUR_W_PIXEL" + [[ -f "$RES_DIMPIXEL" ]] && eval "$convert_command -size $TOTAL_SIZE 'xc:blue' $CUR_W_DIMPIXEL" + [[ -f "$RES_COLOR" ]] && eval "$convert_command -size $TOTAL_SIZE 'xc:blue' $CUR_W_COLOR" + + echof act "Rendering final wallpaper images..." + [[ -f "$CUR_W_RESIZE" ]] && eval "$convert_command $CUR_W_RESIZE $PARAM_RESIZE $CUR_W_RESIZE" + [[ -f "$CUR_W_DIM" ]] && eval "$convert_command $CUR_W_DIM $PARAM_DIM $CUR_W_DIM" + [[ -f "$CUR_W_BLUR" ]] && eval "$convert_command $CUR_W_BLUR $PARAM_BLUR $CUR_W_BLUR" + [[ -f "$CUR_W_DIMBLUR" ]] && eval "$convert_command $CUR_W_DIMBLUR $PARAM_DIMBLUR $CUR_W_DIMBLUR" + [[ -f "$CUR_W_PIXEL" ]] && eval "$convert_command $CUR_W_PIXEL $PARAM_PIXEL $CUR_W_PIXEL" + [[ -f "$CUR_W_DIMPIXEL" ]] && eval "$convert_command $CUR_W_DIMPIXEL $PARAM_DIMPIXEL $CUR_W_DIMPIXEL" + [[ -f "$CUR_W_COLOR" ]] && eval "$convert_command $CUR_W_COLOR $PARAM_COLOR $CUR_W_COLOR" + fi + + echof act "Rendering final lockscreen images..." + + create_loginbox + for pos in "${positions[@]}"; do + PARAM_RECT="$PARAM_RECT $RECTANGLE -geometry $pos -composite " + done + + if [ -n "$description" ]; then + create_description + for descpos in "${positions_desc[@]}"; do + PARAM_RECT="$PARAM_RECT $DESCRECT -geometry $descpos -composite " + done + fi + + [[ -f "$CUR_W_RESIZE" ]] && eval "$convert_command $CUR_W_RESIZE $PARAM_RECT $CUR_L_RESIZE" + [[ -f "$CUR_W_DIM" ]] && eval "$convert_command $CUR_W_DIM $PARAM_RECT $CUR_L_DIM" + [[ -f "$CUR_W_BLUR" ]] && eval "$convert_command $CUR_W_BLUR $PARAM_RECT $CUR_L_BLUR" + [[ -f "$CUR_W_DIMBLUR" ]] && eval "$convert_command $CUR_W_DIMBLUR $PARAM_RECT $CUR_L_DIMBLUR" + [[ -f "$CUR_W_PIXEL" ]] && eval "$convert_command $CUR_W_PIXEL $PARAM_RECT $CUR_L_PIXEL" + [[ -f "$CUR_W_DIMPIXEL" ]] && eval "$convert_command $CUR_W_DIMPIXEL $PARAM_RECT $CUR_L_DIMPIXEL" + [[ -f "$CUR_W_COLOR" ]] && eval "$convert_command $CUR_W_COLOR $PARAM_RECT $CUR_L_COLOR" + + [[ "$RECTANGLE" ]] && rm "$RECTANGLE" + [[ "$DESCRECT" ]] && rm "$DESCRECT" + + echof ok "Done" + +} + +# set wallpaper with effect +wallpaper() { + local effect="$1" + + # make wallpaper span displays + get_display_list + if [ "$span_image" = true ] || [[ "${#DISPLAY_LIST[@]}" -gt 1 ]]; then + wallpaper_cmd="$wallpaper_cmd --no-xinerama" + fi + + # set wallpaper + case "$effect" in + dim) wallpaper="$CUR_W_DIM";; + blur) wallpaper="$CUR_W_BLUR";; + dimblur) wallpaper="$CUR_W_DIMBLUR";; + pixel) wallpaper="$CUR_W_PIXEL";; + dimpixel) wallpaper="$CUR_W_DIMPIXEL";; + color) wallpaper="$CUR_W_COLOR";; + *) wallpaper="$CUR_W_RESIZE";; + esac + eval "$wallpaper_cmd $wallpaper" +} + +# wrap echo with fancy prefix +echof() { + local prefix="$1" + local message="$2" + + case "$prefix" in + header) msgpfx="[\e[1;95mB\e[m]";; + info) msgpfx="[\e[1;97m=\e[m]";; + act) msgpfx="[\e[1;92m*\e[m]";; + ok) msgpfx="[\e[1;93m+\e[m]";; + error) msgpfx="[\e[1;91m!\e[m]";; + *) msgpfx="";; + esac + [ "$quiet" != true ] && echo -e "$msgpfx $message" +} + +# help message +usage() { + echo + echo "Usage: betterlockscreen [-u ] [-l ] [-w ]" + echo + echo " -q --quiet" + echo " Do not produce any text output on locking" + echo + echo " -u --update " + echo " Update lock screen image" + echo + echo " -l --lock " + echo " Lock screen with cached image" + echo + echo " -w --wall " + echo " Set wallpaper with cached image" + echo + echo "Additional arguments:" + echo + echo " --display " + echo " Set display to draw loginbox" + echo + echo " --span" + echo " Scale image to span multiple displays" + echo + echo " --off " + echo " Turn display off after N seconds" + echo + echo " --fx " + echo " List of effects to generate" + echo + echo " --desc " + echo " Set a description for the new lock screen image" + echo " (Only has an effect in combination with --update)" + echo + echo " --show-layout" + echo " Show current keyboard layout" + echo + echo " --wallpaper-cmd " + echo " to set your custom wallpaper setter" + echo + echo " --time-format " + echo " to set the time format used by i3lock-color" + echo + echo " -- " + echo " Pass additional arguments to i3lock" + echo + echo "Effects arguments:" + echo + echo " --dim " + echo " Dim image N percent (0-100)" + echo + echo " --blur " + echo " Blur image N amount (0.0-1.0)" + echo + echo " --pixel " + echo " Pixelate image with N shrink and N grow (unsupported)" + echo + echo " --color " + echo " Solid color background with HEX" + echo + exit 1 +} + +lockargs=(-n) + +init_config + +# show usage when no arguments passed +[[ "$1" = "" ]] && usage + +# process arguments +for arg in "$@"; do + [[ "${arg:0:1}" = '-' ]] || continue + + case "$1" in + + -q | --quiet) + quiet=true + shift + ;; + + -u | --update) + runupdate=true + imagepaths+=("$2") + shift 2 + ;; + + -s | --suspend) + runsuspend=true + ;& + + -l | --lock) + runlock=true + if [[ ${2:0:1} = '-' ]]; then + shift 1 + else + lockstyle="$2"; shift 2 + fi + ;; + + -w | --wall) + wallpaper "$2" + shift 2 + ;; + + --wallpaper-cmd) + wallpaper_cmd="$2" + shift 2 + ;; + + --time-format) + time_format="$2" + shift 2 + ;; + + --display) + display_on="$2" + shift 2 + ;; + + --span) + span_image=true + shift 1 + ;; + + --off) + lock_timeout="$2" + shift 2 + ;; + + --text) + locktext="$2" + shift 2 + ;; + + --show-layout) + keylayout="$2"; + lockargs+=(--keylayout "${keylayout:-0}") + shift 2 + ;; + + --fx) + IFS=',' read -ra fx_list <<< "$2" + shift 2 + ;; + + --dim) + dim_level="$2" + shift 2 + ;; + + --blur) + blur_level="$2" + shift 2 + ;; + + --pixel) + pixel_scale="$2" + shift 2 + ;; + + --color) + solid_color="${2//\#/}" + shift 2 + ;; + + --desc) + description="$2" + shift 2 + ;; + + -v | --version) + echo + echo "Betterlockscreen: version: v$VERSION (dunst: $DUNST_INSTALLED, feh: $FEH_INSTALLED)" + $i3lockcolor_bin --version + $convert_command --version + + if [[ "$DUNST_INSTALLED" == "true" ]]; then + dunstctl debug + fi + + if [[ "$FEH_INSTALLED" == "true" ]]; then + feh --version + fi + + break + ;; + + --) + lockargs+=("${@:2}") + break + ;; + + -h | --help | *) + usage + ;; + esac +done + +echof header "Betterlockscreen" + +# Run image generation +[[ $runupdate ]] && update "${imagepaths[@]}" + +# Activate lockscreen +[[ $runlock ]] && lockinit "$lockstyle" + +exit 0 diff --git a/local-bin/.local/bin/dbeaver-backup.sh b/local-bin/.local/bin/dbeaver-backup.sh new file mode 100755 index 0000000..07626b1 --- /dev/null +++ b/local-bin/.local/bin/dbeaver-backup.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# DBeaver Profile Backup Script +# This script creates a backup of DBeaver profiles and configurations + +# Configuration variables - modify as needed +BACKUP_DIR="/home/forbi/Sync/Backups" +HOSTNAME=$(hostname) +BACKUP_FILE="dbeaver_backup_${HOSTNAME}.tar.gz" +LOG_FILE="$BACKUP_DIR/dbeaver_backup_log.txt" + +# DBeaver configuration location +DBEAVER_DATA="$HOME/.local/share/DBeaverData" # Contains drivers, workspace, and secure storage + +# Create backup directory if it doesn't exist +mkdir -p "$BACKUP_DIR" + +# Start logging +echo "===== DBeaver Backup Started at $(date) =====" >>"$LOG_FILE" + +# Check if DBeaver configuration exists +if [ ! -d "$DBEAVER_DATA" ]; then + echo "Error: DBeaver configuration not found at $DBEAVER_DATA. Please make sure DBeaver is installed and has been run at least once." | tee -a "$LOG_FILE" + exit 1 +fi + +# Create temporary directory for backup +TEMP_DIR=$(mktemp -d) +echo "Created temporary directory: $TEMP_DIR" >>"$LOG_FILE" + +# Copy DBeaver data to temporary directory +echo "Copying DBeaver data from $DBEAVER_DATA..." >>"$LOG_FILE" +cp -r "$DBEAVER_DATA" "$TEMP_DIR/" + +# Create compressed archive +echo "Creating backup archive..." >>"$LOG_FILE" +tar -czf "$BACKUP_DIR/$BACKUP_FILE" -C "$TEMP_DIR" . +BACKUP_RESULT=$? + +# Clean up temporary directory +echo "Cleaning up temporary files..." >>"$LOG_FILE" +rm -rf "$TEMP_DIR" + +# Check if backup was successful +if [ $BACKUP_RESULT -eq 0 ]; then + echo "Backup completed successfully: $BACKUP_DIR/$BACKUP_FILE" | tee -a "$LOG_FILE" + echo "Backup size: $(du -h "$BACKUP_DIR/$BACKUP_FILE" | cut -f1)" | tee -a "$LOG_FILE" + echo "Keeping only the latest backup for this PC ($HOSTNAME)" >>"$LOG_FILE" +else + echo "Error: Backup failed with exit code $BACKUP_RESULT" | tee -a "$LOG_FILE" +fi + +echo "===== DBeaver Backup Finished at $(date) =====" >>"$LOG_FILE" diff --git a/local-bin/.local/bin/dbeaver-restore.sh b/local-bin/.local/bin/dbeaver-restore.sh new file mode 100755 index 0000000..35a143e --- /dev/null +++ b/local-bin/.local/bin/dbeaver-restore.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# DBeaver Profile Restore Script +# This script restores a DBeaver backup created with the backup script + +# Configuration variables - modify as needed +BACKUP_DIR="/home/forbi/Sync/Backups" +HOSTNAME=main +BACKUP_FILE="dbeaver_backup_${HOSTNAME}.tar.gz" +LOG_FILE="$BACKUP_DIR/dbeaver_restore_log.txt" + +# DBeaver configuration location +DBEAVER_DATA="$HOME/.local/share/DBeaverData" + +# Start logging +echo "===== DBeaver Restore Started at $(date) =====" >>"$LOG_FILE" + +# Check if backup file exists +if [ ! -f "$BACKUP_DIR/$BACKUP_FILE" ]; then + echo "Error: Backup file not found at $BACKUP_DIR/$BACKUP_FILE" | tee -a "$LOG_FILE" + exit 1 +fi + +# Check if DBeaver data directory exists and create backup if it does +if [ -d "$DBEAVER_DATA" ]; then + echo "DBeaver data directory exists. Creating backup before restoration..." | tee -a "$LOG_FILE" + TEMP_BACKUP="${DBEAVER_DATA}_backup_$(date +%Y%m%d_%H%M%S)" + mv "$DBEAVER_DATA" "$TEMP_BACKUP" + echo "Original data backed up to: $TEMP_BACKUP" | tee -a "$LOG_FILE" +fi + +# Create temporary directory for extraction +TEMP_DIR=$(mktemp -d) +echo "Created temporary directory for extraction: $TEMP_DIR" >>"$LOG_FILE" + +# Extract backup file +echo "Extracting backup archive..." | tee -a "$LOG_FILE" +tar -xzf "$BACKUP_DIR/$BACKUP_FILE" -C "$TEMP_DIR" +EXTRACT_RESULT=$? + +if [ $EXTRACT_RESULT -ne 0 ]; then + echo "Error: Failed to extract backup with exit code $EXTRACT_RESULT" | tee -a "$LOG_FILE" + rm -rf "$TEMP_DIR" + exit 1 +fi + +# Create target directory if it doesn't exist +mkdir -p "$(dirname "$DBEAVER_DATA")" + +# Copy extracted content to DBeaver data directory +echo "Restoring DBeaver data to $DBEAVER_DATA..." | tee -a "$LOG_FILE" +cp -r "$TEMP_DIR/DBeaverData" "$(dirname "$DBEAVER_DATA")/" +RESTORE_RESULT=$? + +# Clean up temporary directory +echo "Cleaning up temporary files..." >>"$LOG_FILE" +rm -rf "$TEMP_DIR" + +# Check if restore was successful +if [ $RESTORE_RESULT -eq 0 ]; then + echo "Restore completed successfully to: $DBEAVER_DATA" | tee -a "$LOG_FILE" + echo "You may need to restart DBeaver for changes to take effect." | tee -a "$LOG_FILE" +else + echo "Error: Restore failed with exit code $RESTORE_RESULT" | tee -a "$LOG_FILE" + if [ -d "$TEMP_BACKUP" ]; then + echo "Attempting to restore original data from backup..." | tee -a "$LOG_FILE" + rm -rf "$DBEAVER_DATA" + mv "$TEMP_BACKUP" "$DBEAVER_DATA" + echo "Original data restored from backup." | tee -a "$LOG_FILE" + fi +fi + +echo "===== DBeaver Restore Finished at $(date) =====" >>"$LOG_FILE" diff --git a/local-bin/.local/bin/maintenance.sh b/local-bin/.local/bin/maintenance.sh new file mode 100755 index 0000000..2ce982c --- /dev/null +++ b/local-bin/.local/bin/maintenance.sh @@ -0,0 +1,237 @@ +#!/bin/bash + +# Make sure we're running as root or with sudo +if [ "$(id -u)" -ne 0 ]; then + gum style --foreground 196 --bold "This script must be run as root or with sudo" + exit 1 +fi + +# Check if gum is installed +if ! command -v gum &>/dev/null; then + echo "This script uses gum for a nice interface." + echo "Please install gum first: pacman -S gum" + exit 1 +fi + +# Function to print section headers +print_section() { + gum style --border normal --border-foreground 39 --margin "1" --padding "0 2" --bold "$1" +} + +# Function to print tasks +print_task() { + echo "β†’ $1..." +} + +# Function to print success messages +print_success() { + gum style --foreground 46 "βœ“ $1" +} + +# Function to print warning messages +print_warning() { + gum style --foreground 226 "⚠ $1" +} + +# Starting message +# Starting message +echo "=== Arch Linux System Maintenance ===" + +# Update the system +print_section "Updating System" + +# Sync package database +print_task "Synchronizing package databases" +pacman -Sy +print_success "Package databases synchronized" + +# Clean package caches +print_section "Cleaning Package Caches" + +# Clean pacman cache +print_task "Cleaning pacman cache" +pacman -Sc --noconfirm +print_success "Pacman cache cleaned" + +# Clean AUR cache if paru is installed +if command -v paru &>/dev/null; then + print_task "Cleaning paru cache" + paru -Sc --noconfirm + print_success "Paru cache cleaned" +else + print_warning "paru not found. Skipping AUR cache cleanup." +fi + +# Remove orphaned packages +print_section "Removing Orphaned Packages" +print_task "Finding orphaned packages" +ORPHANS=$(pacman -Qtdq) +if [ -n "$ORPHANS" ]; then + echo "Found orphaned packages:" + echo "$ORPHANS" + + print_task "Removing orphaned packages" + pacman -Rns $(pacman -Qtdq) --noconfirm + print_success "Orphaned packages removed" +else + print_success "No orphaned packages found" +fi + +# Clean user cache directory +print_section "Cleaning User Cache Directory" + +# Get current user's username +CURRENT_USER=$(logname 2>/dev/null || echo $SUDO_USER) + +# If we still don't have a username, try to get it from /home +if [ -z "$CURRENT_USER" ]; then + CURRENT_USER=$(ls -la /home | grep -v "\.\." | grep -v "total" | awk '{print $9}' | head -1) +fi + +echo "Cleaning cache for user: $CURRENT_USER" + +# Create a backup directory +BACKUP_DIR="/home/$CURRENT_USER/.cache_backup_$(date +%Y%m%d)" +mkdir -p "$BACKUP_DIR" +chown $CURRENT_USER:$CURRENT_USER "$BACKUP_DIR" + +# User cache directory +USER_CACHE="/home/$CURRENT_USER/.cache" + +if [ -d "$USER_CACHE" ]; then + # Firefox cache + if [ -d "$USER_CACHE/mozilla" ]; then + print_task "Backing up Firefox cache metadata" + cp -r "$USER_CACHE/mozilla" "$BACKUP_DIR/" + print_task "Cleaning Firefox cache" + find "$USER_CACHE/mozilla" -type f -name "*.sqlite" -exec sqlite3 {} "VACUUM;" \; + fi + + # Chrome/Chromium cache + for chrome_dir in "$USER_CACHE/google-chrome" "$USER_CACHE/chromium"; do + if [ -d "$chrome_dir" ]; then + print_task "Backing up Chrome/Chromium cache metadata" + mkdir -p "$BACKUP_DIR/$(basename $chrome_dir)" + cp -r "$chrome_dir/Default/Preferences" "$BACKUP_DIR/$(basename $chrome_dir)/" 2>/dev/null + print_task "Cleaning Chrome/Chromium cache" + rm -rf "$chrome_dir/Default/Cache" "$chrome_dir/Default/Code Cache" 2>/dev/null + fi + done + + # Clean thumbnail cache + if [ -d "$USER_CACHE/thumbnails" ]; then + print_task "Cleaning thumbnail cache" + rm -rf "$USER_CACHE/thumbnails/*" 2>/dev/null + fi + + # General cache cleanup (but preserve important files) + print_task "Cleaning general cache files" + find "$USER_CACHE" -type f -atime +30 -not -path "*/mozilla/*" -not -path "*/chromium/*" -not -path "*/google-chrome/*" -delete 2>/dev/null + + print_success "Cache cleaned for user $CURRENT_USER" +else + print_warning "Cache directory not found for user $CURRENT_USER" +fi + +# Clean system journals +print_section "Cleaning System Journals" +print_task "Rotating and cleaning journal logs" +journalctl --vacuum-time=2weeks +print_success "Journal logs cleaned (kept last 2 weeks)" + +# Reset failed services +print_section "Resetting Failed Systemd Units" +print_task "Checking for failed systemd units" +FAILED_UNITS=$(systemctl --failed --no-legend | awk '{print $1}') +if [ -n "$FAILED_UNITS" ]; then + echo "Failed units found:" + echo "$FAILED_UNITS" +fi +print_task "Clearing failed systemd units" +systemctl reset-failed +print_success "Failed systemd units cleared" + +# Clean temporary files +print_section "Cleaning Temporary Files" +print_task "Removing temporary files" +rm -rf /tmp/* /var/tmp/* 2>/dev/null +print_success "Temporary files removed" + +# Update file database +print_section "Updating File Database" +if command -v updatedb &>/dev/null; then + print_task "Updating file database for locate command" + updatedb + print_success "File database updated" +else + print_warning "updatedb not found. Skipping file database update." +fi + +# Check for and install security updates +print_section "Security Updates Check" +print_task "Checking for security updates" +SECURITY_UPDATES=$(pacman -Qu | grep -i "security") +if [ -n "$SECURITY_UPDATES" ]; then + echo "Security updates available:" + echo "$SECURITY_UPDATES" + + print_task "Installing security updates" + pacman -S --needed $(echo "$SECURITY_UPDATES" | awk '{print $1}') --noconfirm + print_success "Security updates installed" +else + print_success "No security updates needed" +fi + +# Check for pacman database errors +print_section "Checking Pacman Database" +print_task "Verifying package database integrity" +if command -v paccheck &>/dev/null; then + paccheck --md5sum --quiet + print_success "Pacman database check complete" +else + print_warning "paccheck not found. Consider installing pacutils package." +fi + +# Cleanup pacnew/pacsave files +print_section "Configuration File Management" +print_task "Checking for .pacnew and .pacsave files" +PACFILES=$(find /etc -name "*.pacnew" -o -name "*.pacsave" 2>/dev/null) +if [ -n "$PACFILES" ]; then + echo "Found the following .pacnew/.pacsave files:" + echo "$PACFILES" + + print_warning "You may want to merge these configuration files" + echo "Use 'pacdiff' to help manage these files (install pacdiff from pacman-contrib)" +else + print_success "No .pacnew or .pacsave files found" +fi + +# System status +print_section "System Status" + +# Disk usage with duf +print_task "Checking disk usage" +if command -v duf &>/dev/null; then + duf --only local +else + print_warning "duf not found. Using df instead. Consider installing duf for better disk usage display." + df -h | grep -v "tmpfs" | grep -v "udev" +fi + +# Memory usage +echo "Memory usage:" +free -h + +# Find large files +echo "Large files (>100MB) in your home directory:" +find /home/$(logname 2>/dev/null || echo $SUDO_USER) -type f -size +100M -exec ls -lh {} \; 2>/dev/null | sort -k5hr | head -n 10 + +# Final summary +print_section "Maintenance Complete" +echo "System maintenance tasks completed successfully" +echo "Remember to periodically run additional manual maintenance tasks:" +echo "- Check for broken symlinks: find /usr /etc -xtype l -print" +echo "- Run a SMART disk check: smartctl -a /dev/sdX (install smartmontools)" +echo "- Check systemd boot time: systemd-analyze" + +exit 0 diff --git a/local-bin/.local/bin/rmq-passwd b/local-bin/.local/bin/rmq-passwd new file mode 100755 index 0000000..9b5684a --- /dev/null +++ b/local-bin/.local/bin/rmq-passwd @@ -0,0 +1,25 @@ +#!/bin/sh + +PREFIX="oc-" +SUFFIX="-eks-cluster" +FINAL="" + +if [ -z "$1" ]; then + exit 1 +fi + +context="$PREFIX$1$SUFFIX" +current_context=$(kubectl config current-context) + +kubectl config use-context $context >/dev/null +kubectl config set-context --current --namespace=oc-app >/dev/null + +# is second argument provided then silent exit +password=$(kubectl get secret oc-secrets -o jsonpath="{.data.rabbit_passwd}" | base64 --decode) + +printf "$password" | wl-copy +# printf "$password" | xsel --clipboard + +# reset context +kubectl config use-context $current_context >/dev/null +kubectl config set-context --current --namespace=oc-app >/dev/null diff --git a/local-bin/.local/bin/run-on-pod b/local-bin/.local/bin/run-on-pod new file mode 100755 index 0000000..1a583d2 --- /dev/null +++ b/local-bin/.local/bin/run-on-pod @@ -0,0 +1,279 @@ +#!/bin/env bash + +# ARG_OPTIONAL_BOOLEAN([confirm],[c],[Wether to confirm the action or not],[on]) +# ARG_OPTIONAL_SINGLE([runner],[r],[Specify the runner],[]) +# ARG_TYPE_GROUP_SET([commands],[COMMAND],[runner],[node, sh],[index]) +# ARG_POSITIONAL_SINGLE([context],[The Kubernetes context]) +# ARG_POSITIONAL_SINGLE([script],[The script to run]) +# ARG_POSITIONAL_SINGLE([pod_name],[The pod name]) +# ARG_HELP([Prints this help message]) +# ARG_VERSION([1.0]) +# ARG_DEFAULTS_POS([]) +# ARGBASH_GO() +# needed because of Argbash --> m4_ignore([ +### START OF CODE GENERATED BY Argbash v2.10.0 one line above ### +# Argbash is a bash code generator used to get arguments parsing right. +# Argbash is FREE SOFTWARE, see https://argbash.io for more info + +die() { + local _ret="${2:-1}" + test "${_PRINT_HELP:-no}" = yes && print_help >&2 + echo "$1" >&2 + exit "${_ret}" +} + +# validators + +commands() { + local _allowed=("node" "sh") _seeking="$1" _idx=0 + for element in "${_allowed[@]}"; do + test "$element" = "$_seeking" && { test "$3" = "idx" && echo "$_idx" || echo "$element"; } && return 0 + _idx=$((_idx + 1)) + done + die "Value '$_seeking' (of argument '$2') doesn't match the list of allowed values: 'node' and 'sh'" 4 +} + +begins_with_short_option() { + local first_option all_short_options='crhv' + first_option="${1:0:1}" + test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0 +} + +# THE DEFAULTS INITIALIZATION - POSITIONALS +_positionals=() +_arg_context= +_arg_script= +_arg_pod_name= +# THE DEFAULTS INITIALIZATION - OPTIONALS +_arg_confirm="on" +_arg_runner="sh" + +print_help() { + printf '%s\n' "Prints this help message" + printf 'Usage: %s [-c|--(no-)confirm] [-r|--runner ] [-h|--help] [-v|--version]