mirror of
https://github.com/Matir/skel.git
synced 2026-09-22 21:06:56 -07:00
Compare commits
7 Commits
7b8a436e37
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2743349bf6 | ||
|
|
22dd533926 | ||
|
|
4f24a0734f | ||
|
|
f889b6a5f1 | ||
|
|
ae111baa2b | ||
|
|
3666115090 | ||
|
|
6f2494c602 |
@@ -57,9 +57,9 @@ SUB_HOOK_DIR="${HOOKS_DIR}/${CALLED_AS}.d"
|
||||
|
||||
if [ -d "$SUB_HOOK_DIR" ]; then
|
||||
# Sort files naturally so 01- runs before 02-
|
||||
for script in $(ls "$SUB_HOOK_DIR" | sort); do
|
||||
FULL_PATH="$SUB_HOOK_DIR/$script"
|
||||
for FULL_PATH in "$SUB_HOOK_DIR"/*; do
|
||||
[ -x "$FULL_PATH" ] || continue
|
||||
script=$(basename "$FULL_PATH")
|
||||
|
||||
# Replay stdin if we captured it, otherwise execute normally
|
||||
if [ -n "$STDIN_DATA" ]; then
|
||||
|
||||
@@ -125,8 +125,17 @@ function deb_only {
|
||||
function get_latest_github_release_url {
|
||||
local repo="$1"
|
||||
local glob="$2"
|
||||
curl -s "https://api.github.com/repos/${repo}/releases/latest" | \
|
||||
jq -r --arg rx "${glob}" '.assets[] | select(.name | test($rx)) | .browser_download_url'
|
||||
require jq "jq is required to parse GitHub releases."
|
||||
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 {
|
||||
@@ -576,6 +585,57 @@ EOF
|
||||
chmod +x "${DESTDIR}/ssh-agent-mux"
|
||||
add_bin_symlink ssh-agent-mux
|
||||
;;
|
||||
grpcurl)
|
||||
if command -v brew >/dev/null 2>&1; then
|
||||
brew install grpcurl
|
||||
else
|
||||
go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
|
||||
fi
|
||||
;;
|
||||
grpcui)
|
||||
if command -v brew >/dev/null 2>&1; then
|
||||
brew install grpcui
|
||||
else
|
||||
go install github.com/fullstorydev/grpcui/cmd/grpcui@latest
|
||||
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
|
||||
list_tools
|
||||
|
||||
@@ -8,13 +8,18 @@ if [ "$(uname)" != "Linux" ]; then
|
||||
exit 1
|
||||
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}}"
|
||||
|
||||
function verify_dest {
|
||||
arr=($1)
|
||||
items=${#arr[@]}
|
||||
if [ $items -ne 1 ] ; then
|
||||
if [ -z "$1" ] ; then
|
||||
echo "Bad count of backup destinations." > /dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
@@ -25,7 +30,7 @@ function verify_dest {
|
||||
echo -n "Destination $dir does not end in a /, " > /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
|
||||
read
|
||||
read -r
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#!/bin/sh
|
||||
LOCKTIME="${SCREENSAVER_MIN:-5}"
|
||||
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
|
||||
# do not quote this
|
||||
/usr/bin/xss-lock -- ${LOCKER} &
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ $# -lt 1 ] ; then
|
||||
echo "Usage: $0 <kvm|vbox>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ `whoami` != "root" ] ; then
|
||||
if [ "$(id -u)" -ne 0 ] ; then
|
||||
if which sudo >/dev/null 2>&1 ; then
|
||||
sudo "$0" "$@"
|
||||
exit
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ `whoami` != "root" ] ; then
|
||||
if [ "$(id -u)" -ne 0 ] ; then
|
||||
echo "This must be run as root." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BASEDIR=`dirname $0`
|
||||
if ! test -f ${BASEDIR}/keys/gpg/kali-repo.key ; then
|
||||
BASEDIR="$(dirname "$0")"
|
||||
if ! test -f "${BASEDIR}/keys/gpg/kali-repo.key" ; then
|
||||
echo "Couldn't find key, are you in the right place?" >&2
|
||||
exit 1
|
||||
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
|
||||
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 install -y kali-linux-full
|
||||
|
||||
@@ -13,13 +13,15 @@ function disks {
|
||||
local DISKS=(/ /home)
|
||||
local d
|
||||
local used
|
||||
for d in ${DISKS[@]} ; do
|
||||
local dev=`df $d | tail -1 | awk '{print $1}'`
|
||||
if [[ $used == *$dev* ]] ; then
|
||||
for d in "${DISKS[@]}" ; do
|
||||
local dev
|
||||
dev=$(df "$d" | tail -1 | awk '{print $1}')
|
||||
if [[ " $used " == *" $dev "* ]] ; then
|
||||
continue
|
||||
fi
|
||||
local size=`df $d | tail -1 | awk '{print $2}'`
|
||||
if [ $size -eq 0 ] ; then
|
||||
local size
|
||||
size=$(df "$d" | tail -1 | awk '{print $2}')
|
||||
if [ "$size" -eq 0 ] ; then
|
||||
continue
|
||||
fi
|
||||
used="${used} ${dev}"
|
||||
@@ -99,7 +101,9 @@ function battery {
|
||||
status_chr = "↑ CHR"
|
||||
status_bat = "↓ BAT"
|
||||
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
|
||||
cat <<-EOF
|
||||
status_unk = "? UNK"
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
[push]
|
||||
default = current
|
||||
autoSetupRemote = true
|
||||
|
||||
[web]
|
||||
browser = chrome
|
||||
@@ -96,6 +97,7 @@
|
||||
|
||||
[include]
|
||||
path = ~/.gitconfig.d/aliases
|
||||
path = ~/.gitconfig.d/google
|
||||
path = ~/.gitconfig.d/override
|
||||
path = ~/.gitconfig.d/local
|
||||
|
||||
@@ -104,9 +106,14 @@
|
||||
|
||||
[rerere]
|
||||
enabled = true
|
||||
|
||||
[lfs]
|
||||
concurrenttransfers = 3
|
||||
|
||||
[lfs "customtransfer.xet"]
|
||||
path = git-xet
|
||||
args = transfer
|
||||
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
|
||||
# Use the robust awk script for merging.
|
||||
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
|
||||
# Fallback to the old, less robust method if the script is missing.
|
||||
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
|
||||
# Safely replace the original file.
|
||||
cat "$tmpf" >| "${user_hosts}"
|
||||
rm "$tmpf"
|
||||
rm -f "$tmpf"
|
||||
else
|
||||
# User does not have a known_hosts file, just copy the new one.
|
||||
cp "${skel_hosts}" "${user_hosts}"
|
||||
@@ -139,8 +141,7 @@ install_keys() {
|
||||
}
|
||||
|
||||
read_saved_prefs() {
|
||||
# Can't use basedir here as we don't have it yet
|
||||
local pref_file="$(dirname "$0")/.installed-prefs"
|
||||
local pref_file="${SCRIPT_DIR}/.installed-prefs"
|
||||
if [[ -f "${pref_file}" ]] ; then
|
||||
verbose "Loading saved skel preferences from ${pref_file}"
|
||||
# source is a bashism
|
||||
@@ -209,9 +210,17 @@ install_starship() {
|
||||
|
||||
local install_path="${tmpd}/install.sh"
|
||||
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
|
||||
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
|
||||
echo "No curl or wget available!!" >&2
|
||||
rm -rf "${tmpd}"
|
||||
|
||||
Reference in New Issue
Block a user