mirror of
https://github.com/Matir/skel.git
synced 2026-05-25 21:19:09 -07:00
Misc updates
This commit is contained in:
22
README.md
22
README.md
@@ -22,6 +22,28 @@ dotfiles. ;)
|
|||||||
|
|
||||||
### Options ###
|
### Options ###
|
||||||
|
|
||||||
|
### macOS-like Copy/Paste ###
|
||||||
|
|
||||||
|
To address keyboard shortcut conflicts between operating systems, this environment
|
||||||
|
now supports using `Alt+C` for copy and `Alt+V` for paste, similar to macOS.
|
||||||
|
This functionality is context-aware: it will automatically use `Ctrl+Shift+C/V`
|
||||||
|
in terminals and `Ctrl+C/V` in all other applications.
|
||||||
|
|
||||||
|
This feature requires the following packages to be installed:
|
||||||
|
|
||||||
|
- `xbindkeys`: To listen for the keyboard shortcuts.
|
||||||
|
- `xdotool`: To send the appropriate keypresses.
|
||||||
|
|
||||||
|
On Debian-based systems (like Ubuntu or Kali), you can install them with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install xbindkeys xdotool
|
||||||
|
```
|
||||||
|
|
||||||
|
After installation, the functionality will be enabled automatically on your
|
||||||
|
next login.
|
||||||
|
|
||||||
```
|
```
|
||||||
BASEDIR: Where the skel framework is installed. Defaults to $HOME/.skel
|
BASEDIR: Where the skel framework is installed. Defaults to $HOME/.skel
|
||||||
MINIMAL: Don't do things that require git clones or installation of anything
|
MINIMAL: Don't do things that require git clones or installation of anything
|
||||||
|
|||||||
36
bin/smart-copy-paste
Executable file
36
bin/smart-copy-paste
Executable file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# smart-copy-paste
|
||||||
|
#
|
||||||
|
# This script provides context-aware copy and paste operations, mimicking
|
||||||
|
# macOS behavior (Alt+C/V) while correctly handling terminals that require
|
||||||
|
# the Shift key.
|
||||||
|
|
||||||
|
# Exit silently if xdotool is not installed.
|
||||||
|
if ! command -v xdotool > /dev/null; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get the class name of the currently focused window.
|
||||||
|
# We need to get the window on focus, to avoid issues with transparent terminals.
|
||||||
|
class=$(xdotool getwindowclassname "$(xdotool getwindowfocus)")
|
||||||
|
|
||||||
|
# Semicolon-separated list of terminal class names.
|
||||||
|
terminals='Gnome-terminal;Xfce4-terminal;konsole;xterm;URxvt;Terminator;Alacritty;kitty;wezterm'
|
||||||
|
|
||||||
|
# Determine the keystroke based on the window type and the argument passed.
|
||||||
|
if echo "$terminals" | grep -q "$class"; then
|
||||||
|
# This is a terminal, so use Shift.
|
||||||
|
if [ "$1" = "copy" ]; then
|
||||||
|
xdotool key --clearmodifiers ctrl+shift+c
|
||||||
|
elif [ "$1" = "paste" ]; then
|
||||||
|
xdotool key --clearmodifiers ctrl+shift+v
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# This is a standard GUI app.
|
||||||
|
if [ "$1" = "copy" ]; then
|
||||||
|
xdotool key --clearmodifiers ctrl+c
|
||||||
|
elif [ "$1" = "paste" ]; then
|
||||||
|
xdotool key --clearmodifiers ctrl+v
|
||||||
|
fi
|
||||||
|
fi
|
||||||
@@ -1,22 +1,12 @@
|
|||||||
# General aliases, should only be sourced in interactive shells
|
# General aliases, should only be sourced in interactive shells
|
||||||
|
|
||||||
# Add an "alert" alias for long running commands. Use like so:
|
|
||||||
# sleep 10; alert
|
|
||||||
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
|
|
||||||
|
|
||||||
# Cryptsetup alias
|
# Cryptsetup alias
|
||||||
alias luksFormat='cryptsetup luksFormat --type=luks2 --pbkdf-memory=2560000 --pbkdf=argon2id -i 15000 -s 512 -h sha256 -c aes-xts-plain64'
|
alias luksFormat='cryptsetup luksFormat --type=luks2 --pbkdf-memory=2560000 --pbkdf=argon2id -i 15000 -s 512 -h sha256 -c aes-xts-plain64'
|
||||||
|
|
||||||
# Colors
|
|
||||||
if ls --version >/dev/null 2>&1 ; then
|
|
||||||
alias ls='ls --color=auto'
|
|
||||||
fi
|
|
||||||
if [ `uname` != 'Darwin' -a `uname` != 'NetBSD' -a `uname` != 'FreeBSD' -a `uname` != 'OpenBSD' ] ; then
|
|
||||||
# Should have a better way to check for GNU versions
|
|
||||||
alias grep='grep --color=auto'
|
|
||||||
alias egrep='egrep --color=auto'
|
|
||||||
alias fgrep='fgrep --color=auto'
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Easy upgrade
|
# Easy upgrade
|
||||||
alias dist-upgrade="sudo sh -c 'apt-get update && apt-get -y dist-upgrade'"
|
alias dist-upgrade="sudo sh -c 'apt-get update && apt-get -y dist-upgrade'"
|
||||||
@@ -30,8 +20,7 @@ alias mdcode="sed 's/^/ /'"
|
|||||||
# Intel format plz
|
# Intel format plz
|
||||||
alias objdump="command objdump -M intel"
|
alias objdump="command objdump -M intel"
|
||||||
|
|
||||||
# Useful directory utilities
|
|
||||||
alias dircount="for d in * ; do find \$d -type d | wc -l | tr -d '\n' ; echo ' ' \$d ; done | sort -n"
|
|
||||||
|
|
||||||
# Drop caches for swap issues
|
# Drop caches for swap issues
|
||||||
alias drop_caches="echo 3 | sudo /usr/bin/tee /proc/sys/vm/drop_caches"
|
alias drop_caches="echo 3 | sudo /usr/bin/tee /proc/sys/vm/drop_caches"
|
||||||
@@ -41,7 +30,7 @@ alias gettemp='printf "%02.2f\n" "$(cat /sys/class/thermal/thermal_zone0/temp)e-
|
|||||||
|
|
||||||
# get git working directory
|
# get git working directory
|
||||||
alias gitroot="git rev-parse --show-toplevel"
|
alias gitroot="git rev-parse --show-toplevel"
|
||||||
alias cdgr='cd $(git rev-parse --show-toplevel || echo .)'
|
|
||||||
|
|
||||||
# SSH without host key checking
|
# SSH without host key checking
|
||||||
alias sshanon="ssh -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no"
|
alias sshanon="ssh -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no"
|
||||||
|
|||||||
65
dotfiles/config/fish/conf.d/aliases.fish
Normal file
65
dotfiles/config/fish/conf.d/aliases.fish
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
# This script reads a bash-formatted alias file (~/.aliases) and creates
|
||||||
|
# equivalent fish aliases. This allows for sharing aliases between bash and fish.
|
||||||
|
|
||||||
|
# Path to the bash alias file
|
||||||
|
set bash_alias_file ~/.aliases
|
||||||
|
|
||||||
|
# Check if the alias file exists
|
||||||
|
if test -f "$bash_alias_file"
|
||||||
|
# Read the file line by line
|
||||||
|
while read -l line
|
||||||
|
# Skip comments and empty lines
|
||||||
|
if string match -q -r '^\s*#' "$line" || test -z "$line"
|
||||||
|
continue
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check if the line defines an alias
|
||||||
|
if string match -q -r '^\s*alias\s+' "$line"
|
||||||
|
# Remove the 'alias ' prefix
|
||||||
|
set -l definition (string replace -r '^\s*alias\s+' '' "$line")
|
||||||
|
|
||||||
|
# Split the definition into name and value at the first '='
|
||||||
|
set -l parts (string split -m 1 '=' "$definition")
|
||||||
|
set -l alias_name $parts[1]
|
||||||
|
set -l alias_value $parts[2]
|
||||||
|
|
||||||
|
# Remove leading/trailing quotes from the value
|
||||||
|
set -l alias_value (string trim -c "'"" "$alias_value")
|
||||||
|
|
||||||
|
# Define the fish alias
|
||||||
|
alias $alias_name "$alias_value"
|
||||||
|
end
|
||||||
|
end < "$bash_alias_file"
|
||||||
|
end
|
||||||
|
|
||||||
|
# Specific aliases that are not in the bash file
|
||||||
|
|
||||||
|
# On some systems, bat is batcat
|
||||||
|
if not command -v bat >/dev/null 2>&1
|
||||||
|
if command -v batcat >/dev/null 2>&1
|
||||||
|
alias bat (command -v batcat)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# FFUF aliases
|
||||||
|
if command -v ffuf >/dev/null 2>&1
|
||||||
|
if test -d $HOME/tools/seclists
|
||||||
|
alias ffuf-files "ffuf -c -w $HOME/tools/seclists/Discovery/Web-Content/raft-large-files.txt"
|
||||||
|
alias ffuf-dirs "ffuf -c -w $HOME/tools/seclists/Discovery/Web-Content/raft-large-directories.txt"
|
||||||
|
alias ffuf-quick "ffuf -c -w $HOME/tools/seclists/Discovery/Web-Content/quickhits.txt"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if grep --help 2>/dev/null | grep -q 'color'
|
||||||
|
# Should have a better way to check for GNU versions
|
||||||
|
alias grep 'grep --color=auto'
|
||||||
|
alias egrep 'egrep --color=auto'
|
||||||
|
alias fgrep 'fgrep --color=auto'
|
||||||
|
end
|
||||||
|
|
||||||
|
# Detect which `ls` flavor is in use and use the right flag for colors.
|
||||||
|
if ls --help 2>&1 | grep -q -- '--color'
|
||||||
|
alias ls 'ls --color=auto' # GNU `ls`
|
||||||
|
else if test (uname) = "Darwin"
|
||||||
|
alias ls 'ls -G' # macOS `ls`
|
||||||
|
end
|
||||||
@@ -7,6 +7,11 @@ if test -x /opt/homebrew/bin/brew
|
|||||||
if test -d (brew --prefix)"/share/fish/vendor_completions.d"
|
if test -d (brew --prefix)"/share/fish/vendor_completions.d"
|
||||||
set -p fish_complete_path (brew --prefix)/share/fish/vendor_completions.d
|
set -p fish_complete_path (brew --prefix)/share/fish/vendor_completions.d
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# mise, if installed
|
||||||
|
if type -q mise
|
||||||
|
mise hook fish | source
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if command -q starship
|
if command -q starship
|
||||||
|
|||||||
8
dotfiles/config/fish/functions/cdgr.fish
Normal file
8
dotfiles/config/fish/functions/cdgr.fish
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Change to the root of the git repository.
|
||||||
|
# If not in a git repo, do nothing.
|
||||||
|
function cdgr
|
||||||
|
set git_root (git rev-parse --show-toplevel 2>/dev/null)
|
||||||
|
if test -n "$git_root"
|
||||||
|
cd "$git_root"
|
||||||
|
end
|
||||||
|
end
|
||||||
14
dotfiles/config/mise/config.toml
Normal file
14
dotfiles/config/mise/config.toml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[settings]
|
||||||
|
experimental = true
|
||||||
|
|
||||||
|
[settings.pipx]
|
||||||
|
uvx = true
|
||||||
|
|
||||||
|
[settings.python]
|
||||||
|
uv_venv_auto = true
|
||||||
|
|
||||||
|
[tools]
|
||||||
|
uv = "latest"
|
||||||
|
|
||||||
|
[hooks]
|
||||||
|
postinstall = "mise sync python --uv"
|
||||||
8
dotfiles/xbindkeysrc
Normal file
8
dotfiles/xbindkeysrc
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Custom copy/paste mapping for Alt+C and Alt+V to feel more like macOS.
|
||||||
|
# Uses a helper script to send Shift for terminal applications.
|
||||||
|
|
||||||
|
"smart-copy-paste copy"
|
||||||
|
alt + c
|
||||||
|
|
||||||
|
"smart-copy-paste paste"
|
||||||
|
alt + v
|
||||||
@@ -2,4 +2,5 @@ setxkbmap -option ctrl:nocaps -option compose:ralt
|
|||||||
test -x /usr/bin/xsettingsd && /usr/bin/xsettingsd &
|
test -x /usr/bin/xsettingsd && /usr/bin/xsettingsd &
|
||||||
test -f "$HOME/.env" && "$HOME/.env"
|
test -f "$HOME/.env" && "$HOME/.env"
|
||||||
test -f "$HOME/.shenv" && "$HOME/.shenv"
|
test -f "$HOME/.shenv" && "$HOME/.shenv"
|
||||||
|
command -v xbindkeys >/dev/null && xbindkeys &
|
||||||
test -f "$HOME/.profile" && . "$HOME/.profile"
|
test -f "$HOME/.profile" && . "$HOME/.profile"
|
||||||
|
|||||||
@@ -1,8 +1,3 @@
|
|||||||
# Execute code that does not affect the current session in the background.
|
# This file is sourced only for login shells (e.g., SSH sessions, initial TTY logins).
|
||||||
{
|
# For most interactive shells on macOS (like those in Terminal.app or iTerm2), it is NOT sourced.
|
||||||
# Compile the completion dump to increase startup speed.
|
# All active Zsh startup and completion logic has been moved to .zshrc and .zshenv for better consistency and performance.
|
||||||
zcompdump="${ZDOTDIR:-$HOME}/.zcompdump"
|
|
||||||
if [[ -s "$zcompdump" && (! -s "${zcompdump}.zwc" || "$zcompdump" -nt "${zcompdump}.zwc") ]]; then
|
|
||||||
zcompile "$zcompdump"
|
|
||||||
fi
|
|
||||||
} &!
|
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
# For interactive shells
|
# For interactive shells
|
||||||
|
[[ -n "$ZSH_PROFILE" ]] && {
|
||||||
|
zshrc_start_time=$(date +%s.%N)
|
||||||
|
zmodload zsh/zprof
|
||||||
|
}
|
||||||
HISTFILE=~/.zhistory
|
HISTFILE=~/.zhistory
|
||||||
HISTSIZE=10000
|
HISTSIZE=10000
|
||||||
SAVEHIST=10000
|
SAVEHIST=10000
|
||||||
@@ -159,7 +163,7 @@ bindkey '^r' history-incremental-search-backward
|
|||||||
bindkey "^[[3~" delete-char
|
bindkey "^[[3~" delete-char
|
||||||
|
|
||||||
source_if_existing() {
|
source_if_existing() {
|
||||||
if test -e "${1}" ; then source "${1}" ; else false ; fi
|
[[ -f "${1}" ]] && source "${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
source_first_existing() {
|
source_first_existing() {
|
||||||
@@ -196,7 +200,20 @@ if [[ $- == *i* ]] ; then
|
|||||||
zstyle ':compinstall' filename "${HOME}/.zshrc"
|
zstyle ':compinstall' filename "${HOME}/.zshrc"
|
||||||
zstyle ':completion:*' users root ${USER}
|
zstyle ':completion:*' users root ${USER}
|
||||||
# Modules after fpath
|
# Modules after fpath
|
||||||
autoload -Uz compinit && compinit -i
|
autoload -Uz compinit
|
||||||
|
|
||||||
|
# Regenerate zcompdump if it's older than any file in fpath
|
||||||
|
DUMPFILE="${ZDOTDIR:-$HOME}/.zcompdump"
|
||||||
|
updated_files=(${^fpath}(N.om[1]))
|
||||||
|
|
||||||
|
if [[ ! -f "$DUMPFILE" || ( ${#updated_files} -gt 0 && "$updated_files[1]" -nt "$DUMPFILE" ) ]]; then
|
||||||
|
compinit -i -D "$DUMPFILE"
|
||||||
|
# Asynchronously compile the dump file
|
||||||
|
{ zcompile "$DUMPFILE" } &!
|
||||||
|
else
|
||||||
|
compinit -C -i -D "$DUMPFILE"
|
||||||
|
fi
|
||||||
|
unset DUMPFILE updated_files
|
||||||
autoload -Uz promptinit && promptinit
|
autoload -Uz promptinit && promptinit
|
||||||
# Virtualenvwrapper
|
# Virtualenvwrapper
|
||||||
source_first_existing \
|
source_first_existing \
|
||||||
@@ -274,3 +291,11 @@ fi
|
|||||||
|
|
||||||
# Cleanup PATH
|
# Cleanup PATH
|
||||||
typeset -U PATH
|
typeset -U PATH
|
||||||
|
|
||||||
|
if [[ -n "$ZSH_PROFILE" ]]; then
|
||||||
|
zshrc_end_time=$(date +%s.%N)
|
||||||
|
elapsed_seconds=$(echo "$zshrc_end_time - $zshrc_start_time" | bc -l)
|
||||||
|
elapsed_ms=$(printf "%.0f" "$(echo "$elapsed_seconds * 1000" | bc -l)")
|
||||||
|
echo "zshrc done: ${elapsed_ms}ms"
|
||||||
|
zprof
|
||||||
|
fi
|
||||||
|
|||||||
26
dotfiles/zshrc.d/alert.zsh
Normal file
26
dotfiles/zshrc.d/alert.zsh
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
# A function to run a command and send a notification when it's done.
|
||||||
|
# Usage: alert sleep 10
|
||||||
|
|
||||||
|
alert() {
|
||||||
|
# Run the command passed as arguments
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Capture the exit code
|
||||||
|
local ret=$?
|
||||||
|
|
||||||
|
# Determine the icon based on success or failure
|
||||||
|
local icon
|
||||||
|
if [ $ret -eq 0 ]; then
|
||||||
|
icon="terminal"
|
||||||
|
else
|
||||||
|
icon="error"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Send the notification with the executed command
|
||||||
|
notify-send --urgency=low -i "$icon" "Finished: '$@'"
|
||||||
|
|
||||||
|
# Return the original exit code
|
||||||
|
return $ret
|
||||||
|
}
|
||||||
@@ -15,3 +15,17 @@ if command -v ffuf >/dev/null 2>&1 ; then
|
|||||||
alias ffuf-quick="ffuf -c -w $HOME/tools/seclists/Discovery/Web-Content/quickhits.txt"
|
alias ffuf-quick="ffuf -c -w $HOME/tools/seclists/Discovery/Web-Content/quickhits.txt"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if grep --help 2>/dev/null | grep -q 'color'; then
|
||||||
|
# Should have a better way to check for GNU versions
|
||||||
|
alias grep='grep --color=auto'
|
||||||
|
alias egrep='egrep --color=auto'
|
||||||
|
alias fgrep='fgrep --color=auto'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Detect which `ls` flavor is in use and use the right flag for colors.
|
||||||
|
if ls --help 2>&1 | grep -q -- '--color'; then
|
||||||
|
alias ls='ls --color=auto' # GNU `ls`
|
||||||
|
elif [ "$(uname)" = "Darwin" ]; then
|
||||||
|
alias ls='ls -G' # macOS `ls`
|
||||||
|
fi
|
||||||
|
|||||||
9
dotfiles/zshrc.d/cdgr.zsh
Normal file
9
dotfiles/zshrc.d/cdgr.zsh
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Change to the root of the git repository.
|
||||||
|
# If not in a git repo, do nothing.
|
||||||
|
cdgr() {
|
||||||
|
local git_root
|
||||||
|
git_root=$(git rev-parse --show-toplevel 2>/dev/null)
|
||||||
|
if [ -n "$git_root" ]; then
|
||||||
|
cd "$git_root"
|
||||||
|
fi
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user