mirror of
https://github.com/Matir/skel.git
synced 2026-09-22 21:06:56 -07:00
Compare commits
5 Commits
3666115090
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2743349bf6 | ||
|
|
22dd533926 | ||
|
|
4f24a0734f | ||
|
|
f889b6a5f1 | ||
|
|
ae111baa2b |
@@ -57,9 +57,9 @@ SUB_HOOK_DIR="${HOOKS_DIR}/${CALLED_AS}.d"
|
|||||||
|
|
||||||
if [ -d "$SUB_HOOK_DIR" ]; then
|
if [ -d "$SUB_HOOK_DIR" ]; then
|
||||||
# Sort files naturally so 01- runs before 02-
|
# Sort files naturally so 01- runs before 02-
|
||||||
for script in $(ls "$SUB_HOOK_DIR" | sort); do
|
for FULL_PATH in "$SUB_HOOK_DIR"/*; do
|
||||||
FULL_PATH="$SUB_HOOK_DIR/$script"
|
|
||||||
[ -x "$FULL_PATH" ] || continue
|
[ -x "$FULL_PATH" ] || continue
|
||||||
|
script=$(basename "$FULL_PATH")
|
||||||
|
|
||||||
# Replay stdin if we captured it, otherwise execute normally
|
# Replay stdin if we captured it, otherwise execute normally
|
||||||
if [ -n "$STDIN_DATA" ]; then
|
if [ -n "$STDIN_DATA" ]; then
|
||||||
|
|||||||
@@ -125,8 +125,17 @@ function deb_only {
|
|||||||
function get_latest_github_release_url {
|
function get_latest_github_release_url {
|
||||||
local repo="$1"
|
local repo="$1"
|
||||||
local glob="$2"
|
local glob="$2"
|
||||||
curl -s "https://api.github.com/repos/${repo}/releases/latest" | \
|
require jq "jq is required to parse GitHub releases."
|
||||||
jq -r --arg rx "${glob}" '.assets[] | select(.name | test($rx)) | .browser_download_url'
|
local response
|
||||||
|
response=$(curl -s "https://api.github.com/repos/${repo}/releases/latest")
|
||||||
|
|
||||||
|
if ! echo "${response}" | jq -e '.assets' >/dev/null 2>&1; then
|
||||||
|
local msg
|
||||||
|
msg=$(echo "${response}" | jq -r '.message // "Unknown error fetching latest release."')
|
||||||
|
die "GitHub API error for ${repo}: ${msg}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "${response}" | jq -r --arg rx "${glob}" '.assets[] | select(.name | test($rx)) | .browser_download_url'
|
||||||
}
|
}
|
||||||
|
|
||||||
function require {
|
function require {
|
||||||
@@ -590,6 +599,43 @@ EOF
|
|||||||
go install github.com/fullstorydev/grpcui/cmd/grpcui@latest
|
go install github.com/fullstorydev/grpcui/cmd/grpcui@latest
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
difftastic)
|
||||||
|
if command -v brew >/dev/null 2>&1; then
|
||||||
|
brew install difftastic
|
||||||
|
else
|
||||||
|
makedest_or_die
|
||||||
|
case "$(uname -s)" in
|
||||||
|
Linux)
|
||||||
|
target_os="unknown-linux-gnu"
|
||||||
|
;;
|
||||||
|
Darwin)
|
||||||
|
target_os="apple-darwin"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
die "Unsupported OS: $(uname -s)"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case "$(uname -m)" in
|
||||||
|
x86_64|amd64)
|
||||||
|
arch="x86_64"
|
||||||
|
;;
|
||||||
|
aarch64|arm64)
|
||||||
|
arch="aarch64"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
die "Unsupported architecture: $(uname -m)"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
tar_url=$(get_latest_github_release_url "Wilfred/difftastic" "^difft-${arch}-${target_os}\\.tar\\.gz$")
|
||||||
|
if [ -z "${tar_url}" ]; then
|
||||||
|
die "Could not find difftastic release for ${arch}-${target_os}"
|
||||||
|
fi
|
||||||
|
download "${tar_url}" "${TMPDIR}/difftastic.tar.gz"
|
||||||
|
tar zxf "${TMPDIR}/difftastic.tar.gz" -C "${DESTDIR}"
|
||||||
|
chmod +x "${DESTDIR}/difft"
|
||||||
|
add_bin_symlink difft
|
||||||
|
fi
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown tool: ${TOOL}" >/dev/stderr
|
echo "Unknown tool: ${TOOL}" >/dev/stderr
|
||||||
list_tools
|
list_tools
|
||||||
|
|||||||
@@ -8,13 +8,18 @@ if [ "$(uname)" != "Linux" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DEFAULT=`echo /media/${USER}/[bB]ackup/${USER}/`
|
shopt -s nullglob
|
||||||
|
matches=( /media/"${USER}"/[bB]ackup/"${USER}"/ )
|
||||||
|
shopt -u nullglob
|
||||||
|
if [ ${#matches[@]} -gt 0 ]; then
|
||||||
|
DEFAULT="${matches[0]}"
|
||||||
|
else
|
||||||
|
DEFAULT="/media/${USER}/Backup/${USER}/"
|
||||||
|
fi
|
||||||
DEST="${1:-${DEFAULT}}"
|
DEST="${1:-${DEFAULT}}"
|
||||||
|
|
||||||
function verify_dest {
|
function verify_dest {
|
||||||
arr=($1)
|
if [ -z "$1" ] ; then
|
||||||
items=${#arr[@]}
|
|
||||||
if [ $items -ne 1 ] ; then
|
|
||||||
echo "Bad count of backup destinations." > /dev/stderr
|
echo "Bad count of backup destinations." > /dev/stderr
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -25,7 +30,7 @@ function verify_dest {
|
|||||||
echo -n "Destination $dir does not end in a /, " > /dev/stderr
|
echo -n "Destination $dir does not end in a /, " > /dev/stderr
|
||||||
echo "this is probably not what you want!" > /dev/stderr
|
echo "this is probably not what you want!" > /dev/stderr
|
||||||
echo "Press a key to continue, or CTRL-C to cancel." > /dev/stderr
|
echo "Press a key to continue, or CTRL-C to cancel." > /dev/stderr
|
||||||
read
|
read -r
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
LOCKTIME="${SCREENSAVER_MIN:-5}"
|
LOCKTIME="${SCREENSAVER_MIN:-5}"
|
||||||
LOCKER="i3lock -c 000000"
|
LOCKER="i3lock -c 000000"
|
||||||
|
# Cleanup previously leaked background agents
|
||||||
|
pkill -x xss-lock 2>/dev/null || true
|
||||||
|
pkill -x xautolock 2>/dev/null || true
|
||||||
|
|
||||||
# intentionally want word splitting below
|
# intentionally want word splitting below
|
||||||
# do not quote this
|
# do not quote this
|
||||||
/usr/bin/xss-lock -- ${LOCKER} &
|
/usr/bin/xss-lock -- ${LOCKER} &
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
if [ $# -lt 1 ] ; then
|
if [ $# -lt 1 ] ; then
|
||||||
echo "Usage: $0 <kvm|vbox>" >&2
|
echo "Usage: $0 <kvm|vbox>" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ `whoami` != "root" ] ; then
|
if [ "$(id -u)" -ne 0 ] ; then
|
||||||
if which sudo >/dev/null 2>&1 ; then
|
if which sudo >/dev/null 2>&1 ; then
|
||||||
sudo "$0" "$@"
|
sudo "$0" "$@"
|
||||||
exit
|
exit
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ `whoami` != "root" ] ; then
|
if [ "$(id -u)" -ne 0 ] ; then
|
||||||
echo "This must be run as root." >&2
|
echo "This must be run as root." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BASEDIR=`dirname $0`
|
BASEDIR="$(dirname "$0")"
|
||||||
if ! test -f ${BASEDIR}/keys/gpg/kali-repo.key ; then
|
if ! test -f "${BASEDIR}/keys/gpg/kali-repo.key" ; then
|
||||||
echo "Couldn't find key, are you in the right place?" >&2
|
echo "Couldn't find key, are you in the right place?" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -15,6 +15,6 @@ cat >/etc/apt/sources.list.d/kali.list <<KALI_EOF
|
|||||||
deb http://http.kali.org/kali kali-rolling main contrib non-free
|
deb http://http.kali.org/kali kali-rolling main contrib non-free
|
||||||
KALI_EOF
|
KALI_EOF
|
||||||
|
|
||||||
/usr/bin/apt-key add ${BASEDIR}/keys/gpg/kali-repo.key
|
/usr/bin/apt-key add "${BASEDIR}/keys/gpg/kali-repo.key"
|
||||||
/usr/bin/apt-get update
|
/usr/bin/apt-get update
|
||||||
/usr/bin/apt-get install -y kali-linux-full
|
/usr/bin/apt-get install -y kali-linux-full
|
||||||
|
|||||||
@@ -13,13 +13,15 @@ function disks {
|
|||||||
local DISKS=(/ /home)
|
local DISKS=(/ /home)
|
||||||
local d
|
local d
|
||||||
local used
|
local used
|
||||||
for d in ${DISKS[@]} ; do
|
for d in "${DISKS[@]}" ; do
|
||||||
local dev=`df $d | tail -1 | awk '{print $1}'`
|
local dev
|
||||||
if [[ $used == *$dev* ]] ; then
|
dev=$(df "$d" | tail -1 | awk '{print $1}')
|
||||||
|
if [[ " $used " == *" $dev "* ]] ; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
local size=`df $d | tail -1 | awk '{print $2}'`
|
local size
|
||||||
if [ $size -eq 0 ] ; then
|
size=$(df "$d" | tail -1 | awk '{print $2}')
|
||||||
|
if [ "$size" -eq 0 ] ; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
used="${used} ${dev}"
|
used="${used} ${dev}"
|
||||||
@@ -99,7 +101,9 @@ function battery {
|
|||||||
status_chr = "↑ CHR"
|
status_chr = "↑ CHR"
|
||||||
status_bat = "↓ BAT"
|
status_bat = "↓ BAT"
|
||||||
EOF
|
EOF
|
||||||
if [ $(bc <<< "$(i3status --version | awk '{print $2}') < 2.11") -eq 0 ] ;
|
local i3ver
|
||||||
|
i3ver=$(i3status --version 2>/dev/null | awk '{print $2}')
|
||||||
|
if [ -z "$i3ver" ] || [ "$(bc <<< "$i3ver < 2.11" 2>/dev/null)" -eq 0 ] ;
|
||||||
then
|
then
|
||||||
cat <<-EOF
|
cat <<-EOF
|
||||||
status_unk = "? UNK"
|
status_unk = "? UNK"
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
[push]
|
[push]
|
||||||
default = current
|
default = current
|
||||||
|
autoSetupRemote = true
|
||||||
|
|
||||||
[web]
|
[web]
|
||||||
browser = chrome
|
browser = chrome
|
||||||
@@ -105,9 +106,14 @@
|
|||||||
|
|
||||||
[rerere]
|
[rerere]
|
||||||
enabled = true
|
enabled = true
|
||||||
|
|
||||||
[lfs]
|
[lfs]
|
||||||
concurrenttransfers = 3
|
concurrenttransfers = 3
|
||||||
|
|
||||||
[lfs "customtransfer.xet"]
|
[lfs "customtransfer.xet"]
|
||||||
path = git-xet
|
path = git-xet
|
||||||
args = transfer
|
args = transfer
|
||||||
concurrent = true
|
concurrent = true
|
||||||
|
|
||||||
|
[branch]
|
||||||
|
autoSetupMerge = simple
|
||||||
|
|||||||
49
dotfiles/local/bin/git-diff-smart-pager
Executable file
49
dotfiles/local/bin/git-diff-smart-pager
Executable file
@@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Detect installed binaries
|
||||||
|
HAS_DELTA=$(command -v delta 2>/dev/null || true)
|
||||||
|
HAS_DIFFT=$(command -v difft 2>/dev/null || true)
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
# MODE 1: GIT_EXTERNAL_DIFF / diff.external
|
||||||
|
# Git passes exactly 7 arguments:
|
||||||
|
# $1: path $2: old-file $3: old-hex $4: old-mode $5: new-file $6: new-hex $7: new-mode
|
||||||
|
# ==============================================================================
|
||||||
|
if [ "$#" -eq 7 ]; then
|
||||||
|
DISPLAY_PATH="$1"
|
||||||
|
OLD_FILE="$2"
|
||||||
|
NEW_FILE="$5"
|
||||||
|
|
||||||
|
# 1. Difftastic installed -> Native AST structural file comparison
|
||||||
|
if [ -n "$HAS_DIFFT" ]; then
|
||||||
|
# Pass file metadata and display path to difft
|
||||||
|
exec difft --display=side-by-side-show-both "$OLD_FILE" "$NEW_FILE"
|
||||||
|
|
||||||
|
# 2. Delta installed (Difftastic missing) -> Standard diff piped into delta
|
||||||
|
elif [ -n "$HAS_DELTA" ]; then
|
||||||
|
diff -u -p --label "a/$DISPLAY_PATH" "$OLD_FILE" --label "b/$DISPLAY_PATH" "$NEW_FILE" | delta
|
||||||
|
|
||||||
|
# 3. Neither installed -> Standard unified diff
|
||||||
|
else
|
||||||
|
diff -u -p --label "a/$DISPLAY_PATH" "$OLD_FILE" --label "b/$DISPLAY_PATH" "$NEW_FILE" || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
# MODE 2: GIT_PAGER / core.pager
|
||||||
|
# Invoked as a downstream filter/pager for stdout (stdin contains diff/log output)
|
||||||
|
# ==============================================================================
|
||||||
|
else
|
||||||
|
# 1. Delta installed -> Rich pager for git log, git show, git diff, etc.
|
||||||
|
if [ -n "$HAS_DELTA" ]; then
|
||||||
|
exec delta "$@"
|
||||||
|
|
||||||
|
# 2. Difftastic installed (Delta missing) -> Read unified diff from stdin
|
||||||
|
elif [ -n "$HAS_DIFFT" ]; then
|
||||||
|
exec difft "$@"
|
||||||
|
|
||||||
|
# 3. Neither installed -> Fall back to system pager
|
||||||
|
else
|
||||||
|
exec "${PAGER:-less}" ${LESS:--FRX} "$@"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
27
install.sh
27
install.sh
@@ -114,15 +114,17 @@ install_known_hosts() {
|
|||||||
if [[ -x "${merge_script}" ]]; then
|
if [[ -x "${merge_script}" ]]; then
|
||||||
# Use the robust awk script for merging.
|
# Use the robust awk script for merging.
|
||||||
verbose "Merging known_hosts with authoritative script..."
|
verbose "Merging known_hosts with authoritative script..."
|
||||||
"${merge_script}" "${skel_hosts}" "${user_hosts}" > "$tmpf"
|
if "${merge_script}" "${skel_hosts}" "${user_hosts}" > "$tmpf"; then
|
||||||
|
cat "$tmpf" >| "${user_hosts}"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# Fallback to the old, less robust method if the script is missing.
|
# Fallback to the old, less robust method if the script is missing.
|
||||||
verbose "Warning: ${merge_script} not found or not executable. Using simple sort."
|
verbose "Warning: ${merge_script} not found or not executable. Using simple sort."
|
||||||
cat "${skel_hosts}" "${user_hosts}" | sort -u > "$tmpf"
|
if cat "${skel_hosts}" "${user_hosts}" | sort -u > "$tmpf"; then
|
||||||
|
cat "$tmpf" >| "${user_hosts}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
# Safely replace the original file.
|
rm -f "$tmpf"
|
||||||
cat "$tmpf" >| "${user_hosts}"
|
|
||||||
rm "$tmpf"
|
|
||||||
else
|
else
|
||||||
# User does not have a known_hosts file, just copy the new one.
|
# User does not have a known_hosts file, just copy the new one.
|
||||||
cp "${skel_hosts}" "${user_hosts}"
|
cp "${skel_hosts}" "${user_hosts}"
|
||||||
@@ -139,8 +141,7 @@ install_keys() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
read_saved_prefs() {
|
read_saved_prefs() {
|
||||||
# Can't use basedir here as we don't have it yet
|
local pref_file="${SCRIPT_DIR}/.installed-prefs"
|
||||||
local pref_file="$(dirname "$0")/.installed-prefs"
|
|
||||||
if [[ -f "${pref_file}" ]] ; then
|
if [[ -f "${pref_file}" ]] ; then
|
||||||
verbose "Loading saved skel preferences from ${pref_file}"
|
verbose "Loading saved skel preferences from ${pref_file}"
|
||||||
# source is a bashism
|
# source is a bashism
|
||||||
@@ -209,9 +210,17 @@ install_starship() {
|
|||||||
|
|
||||||
local install_path="${tmpd}/install.sh"
|
local install_path="${tmpd}/install.sh"
|
||||||
if have_command curl ; then
|
if have_command curl ; then
|
||||||
curl -sSL --show-error -o "${install_path}" https://starship.rs/install.sh
|
if ! curl -fsSL --show-error -o "${install_path}" https://starship.rs/install.sh; then
|
||||||
|
echo "Failed to download starship installer!" >&2
|
||||||
|
rm -rf "${tmpd}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
elif have_command wget ; then
|
elif have_command wget ; then
|
||||||
wget -q -O "${install_path}" --https-only https://starship.rs/install.sh
|
if ! wget -q -O "${install_path}" --https-only https://starship.rs/install.sh; then
|
||||||
|
echo "Failed to download starship installer!" >&2
|
||||||
|
rm -rf "${tmpd}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "No curl or wget available!!" >&2
|
echo "No curl or wget available!!" >&2
|
||||||
rm -rf "${tmpd}"
|
rm -rf "${tmpd}"
|
||||||
|
|||||||
Reference in New Issue
Block a user