mirror of
https://github.com/Matir/skel.git
synced 2026-05-25 21:19:09 -07:00
Merge branch 'main' of github.com:Matir/skel
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
# General aliases, should only be sourced in interactive shells
|
||||
# Try to keep in sync with ~/.config/fish/conf.d/aliases.fish
|
||||
|
||||
# Cryptsetup alias
|
||||
alias luksFormat='cryptsetup luksFormat --type=luks2 --pbkdf-memory=2560000 --pbkdf=argon2id -i 15000 -s 512 -h sha256 -c aes-xts-plain64'
|
||||
|
||||
# Timestamp in a machine-sortable form
|
||||
alias tstamp="date '+%Y%m%d-%H%M%S'"
|
||||
|
||||
@@ -13,12 +10,6 @@ alias mdcode="sed 's/^/ /'"
|
||||
# Intel format plz
|
||||
alias objdump="command objdump -M intel"
|
||||
|
||||
# Drop caches for swap issues
|
||||
alias drop_caches="echo 3 | sudo /usr/bin/tee /proc/sys/vm/drop_caches"
|
||||
|
||||
# dump acpi temperature
|
||||
alias gettemp='printf "%02.2f\n" "$(cat /sys/class/thermal/thermal_zone0/temp)e-3"'
|
||||
|
||||
# get git working directory
|
||||
alias gitroot="git rev-parse --show-toplevel"
|
||||
|
||||
@@ -31,20 +22,37 @@ alias ipy="ipython3 --no-banner"
|
||||
# Skip the header on bc
|
||||
alias bc="command bc -q"
|
||||
|
||||
# Get a decently readable df
|
||||
alias dfh="df -h -x tmpfs -x devtmpfs -x squashfs -x fuse -x efivarfs"
|
||||
|
||||
# Clear the GPG agent
|
||||
alias clear-gpg-agent="echo RELOADAGENT | gpg-connect-agent"
|
||||
|
||||
# Battery details
|
||||
alias bat-details='upower -i $(upower -e | grep battery)'
|
||||
|
||||
# Nvidia refresh rate
|
||||
alias nvidia-refresh-rate='nvidia-settings --display=:0 -q RefreshRate -t'
|
||||
|
||||
# Earthly ssh
|
||||
alias earthly='earthly --ssh-auth-sock ""'
|
||||
|
||||
# to clipboard
|
||||
alias toclip='xclip -selection clipboard'
|
||||
if [ "$(uname)" = "Linux" ]; then
|
||||
# Cryptsetup alias
|
||||
alias luksFormat='cryptsetup luksFormat --type=luks2 --pbkdf-memory=2560000 --pbkdf=argon2id -i 15000 -s 512 -h sha256 -c aes-xts-plain64'
|
||||
|
||||
# Drop caches for swap issues
|
||||
alias drop_caches="echo 3 | sudo /usr/bin/tee /proc/sys/vm/drop_caches"
|
||||
|
||||
# dump acpi temperature
|
||||
alias gettemp='printf "%02.2f\n" "$(cat /sys/class/thermal/thermal_zone0/temp)e-3"'
|
||||
|
||||
# Get a decently readable df
|
||||
alias dfh="df -h -x tmpfs -x devtmpfs -x squashfs -x fuse -x efivarfs"
|
||||
|
||||
# Battery details
|
||||
alias bat-details='upower -i $(upower -e | grep battery)'
|
||||
|
||||
# Nvidia refresh rate
|
||||
alias nvidia-refresh-rate='nvidia-settings --display=:0 -q RefreshRate -t'
|
||||
|
||||
# to clipboard
|
||||
alias toclip='xclip -selection clipboard'
|
||||
elif [ "$(uname)" = "Darwin" ]; then
|
||||
# Get a decently readable df
|
||||
alias dfh="df -h"
|
||||
|
||||
# to clipboard
|
||||
alias toclip='pbcopy'
|
||||
fi
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
# Cryptsetup alias
|
||||
alias luksFormat 'cryptsetup luksFormat --type=luks2 --pbkdf-memory=2560000 --pbkdf=argon2id -i 15000 -s 512 -h sha256 -c aes-xts-plain64'
|
||||
|
||||
# Timestamp in a machine-sortable form
|
||||
alias tstamp "date '+%Y%m%d-%H%M%S'"
|
||||
|
||||
@@ -10,12 +7,6 @@ alias mdcode "sed 's/^/ /'"
|
||||
# Intel format plz
|
||||
alias objdump "command objdump -M intel"
|
||||
|
||||
# Drop caches for swap issues
|
||||
alias drop_caches "echo 3 | sudo /usr/bin/tee /proc/sys/vm/drop_caches"
|
||||
|
||||
# dump acpi temperature
|
||||
alias gettemp 'printf "%02.2f\n" (cat /sys/class/thermal/thermal_zone0/temp)e-3'
|
||||
|
||||
# get git working directory
|
||||
alias gitroot "git rev-parse --show-toplevel"
|
||||
|
||||
@@ -28,23 +19,40 @@ alias ipy "ipython3 --no-banner"
|
||||
# Skip the header on bc
|
||||
alias bc "command bc -q"
|
||||
|
||||
# Get a decently readable df
|
||||
alias dfh "df -h -x tmpfs -x devtmpfs -x squashfs -x fuse -x efivarfs"
|
||||
|
||||
# Clear the GPG agent
|
||||
alias clear-gpg-agent "echo RELOADAGENT | gpg-connect-agent"
|
||||
|
||||
# Battery details
|
||||
alias bat-details 'upower -i (upower -e | grep battery)'
|
||||
|
||||
# Nvidia refresh rate
|
||||
alias nvidia-refresh-rate 'nvidia-settings --display=:0 -q RefreshRate -t'
|
||||
|
||||
# Earthly ssh
|
||||
alias earthly 'earthly --ssh-auth-sock ""'
|
||||
|
||||
# to clipboard
|
||||
alias toclip 'xclip -selection clipboard'
|
||||
if test (uname) = "Linux"
|
||||
# Cryptsetup alias
|
||||
alias luksFormat 'cryptsetup luksFormat --type=luks2 --pbkdf-memory=2560000 --pbkdf=argon2id -i 15000 -s 512 -h sha256 -c aes-xts-plain64'
|
||||
|
||||
# Drop caches for swap issues
|
||||
alias drop_caches "echo 3 | sudo /usr/bin/tee /proc/sys/vm/drop_caches"
|
||||
|
||||
# dump acpi temperature
|
||||
alias gettemp 'printf "%02.2f\n" (cat /sys/class/thermal/thermal_zone0/temp)e-3'
|
||||
|
||||
# Get a decently readable df
|
||||
alias dfh "df -h -x tmpfs -x devtmpfs -x squashfs -x fuse -x efivarfs"
|
||||
|
||||
# Battery details
|
||||
alias bat-details 'upower -i (upower -e | grep battery)'
|
||||
|
||||
# Nvidia refresh rate
|
||||
alias nvidia-refresh-rate 'nvidia-settings --display=:0 -q RefreshRate -t'
|
||||
|
||||
# to clipboard
|
||||
alias toclip 'xclip -selection clipboard'
|
||||
else if test (uname) = "Darwin"
|
||||
# Get a decently readable df
|
||||
alias dfh "df -h"
|
||||
|
||||
# to clipboard
|
||||
alias toclip 'pbcopy'
|
||||
end
|
||||
|
||||
# On some systems, bat is batcat
|
||||
if not command -v bat >/dev/null 2>&1
|
||||
|
||||
@@ -34,4 +34,6 @@ end
|
||||
fish_add_path --move --path {$HOME}/bin
|
||||
if test (uname) = "Darwin"
|
||||
fish_add_path --move --path {$HOME}/bin/macos
|
||||
else if test (uname) = "Linux"
|
||||
fish_add_path --move --path {$HOME}/bin/linux
|
||||
end
|
||||
|
||||
@@ -24,9 +24,9 @@
|
||||
last = log -1 HEAD
|
||||
# Thanks to
|
||||
# http://durdn.com/blog/2012/11/22/must-have-git-aliases-advanced-examples/
|
||||
logs = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
|
||||
logs = log --pretty=format:"%C(yellow)%h%Cred%d %Creset%s%Cblue [%cn]" --decorate
|
||||
lg = log -p
|
||||
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
|
||||
ll = log --pretty=format:"%C(yellow)%h%Cred%d %Creset%s%Cblue [%cn]" --decorate --numstat
|
||||
files = ls-files
|
||||
ls = ls-files
|
||||
lol = log --graph --pretty=format:'%C(yellow)%h%Creset %an: %s - %Creset %C(yellow)%d%Creset %Cblue(%cr)%Creset' --abbrev-commit --date=relative
|
||||
@@ -92,8 +92,12 @@
|
||||
process = git-lfs filter-process
|
||||
|
||||
[include]
|
||||
path = ~/.gitconfig.d/aliases
|
||||
path = ~/.gitconfig.d/override
|
||||
path = ~/.gitconfig.d/local
|
||||
|
||||
[includeIf "gitdir:~/personal/"]
|
||||
[includeIf "gitdir/i:~/personal/"]
|
||||
path = ~/.gitconfig.d/personal
|
||||
|
||||
[rerere]
|
||||
enabled = true
|
||||
|
||||
9
dotfiles/gitconfig.d/aliases
Normal file
9
dotfiles/gitconfig.d/aliases
Normal file
@@ -0,0 +1,9 @@
|
||||
[alias]
|
||||
commit-assumed = "!f() { \
|
||||
file=\"$1\"; \
|
||||
shift; \
|
||||
git update-index --no-assume-unchanged \"$file\" && \
|
||||
git add \"$file\" && \
|
||||
git commit \"$@\" && \
|
||||
git update-index --assume-unchanged \"$file\"; \
|
||||
}; f"
|
||||
@@ -113,13 +113,17 @@ _is_link_path() {
|
||||
|
||||
_CANDIDATE=""
|
||||
|
||||
# 1. If current environment has a valid socket that is NOT our link, it's a prime candidate (e.g. SSH forwarding).
|
||||
# 1. If current environment has a valid socket that is NOT our link, it's a prime candidate
|
||||
# (e.g. fresh SSH login: sshd sets SSH_AUTH_SOCK to the raw forwarded socket before ssh/rc
|
||||
# rewrites it to the stable symlink; the shell inherits the original raw path).
|
||||
if [ -S "${SSH_AUTH_SOCK:-}" ] && ! _is_link_path "${SSH_AUTH_SOCK}"; then
|
||||
_CANDIDATE="${SSH_AUTH_SOCK}"
|
||||
fi
|
||||
|
||||
# 2. If no candidate yet, or we're currently using the link, try to find the "real" system agent.
|
||||
if [ -z "${_CANDIDATE}" ] || _is_link_path "${SSH_AUTH_SOCK:-}"; then
|
||||
# 2. Only look for a system agent if the stable link is already broken. If the link is
|
||||
# valid (e.g. a tmux pane where SSH_AUTH_SOCK points to our symlink which ssh/rc just
|
||||
# updated to the forwarded socket), leave it alone — don't clobber it with a local agent.
|
||||
if [ -z "${_CANDIDATE}" ] && [ ! -S "${_SSH_AUTH_LINK}" ]; then
|
||||
_FOUND=""
|
||||
if [ "$(uname)" = "Darwin" ]; then
|
||||
_FOUND=$(launchctl getenv SSH_AUTH_SOCK 2>/dev/null)
|
||||
@@ -143,8 +147,8 @@ if [ -z "${_CANDIDATE}" ] || _is_link_path "${SSH_AUTH_SOCK:-}"; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# 3. Last resort: search common paths if we still don't have a valid candidate.
|
||||
if [ ! -S "${_CANDIDATE}" ]; then
|
||||
# 3. Last resort: search common paths if we still don't have a candidate and the link is broken.
|
||||
if [ ! -S "${_CANDIDATE}" ] && [ ! -S "${_SSH_AUTH_LINK}" ]; then
|
||||
_U=$(id -u)
|
||||
for _p in "/run/user/${_U}/keyring/ssh" "/run/user/${_U}/ssh-agent.socket" "/run/user/${_U}/openssh_agent" "/run/user/${_U}/gnupg/S.gpg-agent.ssh"; do
|
||||
if [ -S "${_p}" ] && ! _is_link_path "${_p}"; then
|
||||
@@ -190,6 +194,8 @@ if [ "$(uname)" = "Darwin" ] ; then
|
||||
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-$TMPDIR/runtime-$(id -u)}"
|
||||
export XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"
|
||||
export PATH="${HOME}/bin/macos:${PATH}"
|
||||
elif [ "$(uname)" = "Linux" ] ; then
|
||||
export PATH="${HOME}/bin/linux:${PATH}"
|
||||
fi
|
||||
|
||||
if test -e "$HOME/.localenv"; then
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
|
||||
# Roughly based on this article:
|
||||
# https://werat.github.io/2017/02/04/tmux-ssh-agent-forwarding.html
|
||||
#
|
||||
# NOTE: this file is executed by sshd as a child process, NOT sourced by the
|
||||
# user's shell. Any variable assignments or exports here have no effect on the
|
||||
# shell environment the user will land in.
|
||||
|
||||
REMOTE_LINK="${HOME}/.ssh/ssh_auth_sock"
|
||||
|
||||
if [ -S "${SSH_AUTH_SOCK}" ] ; then
|
||||
SSH_REMOTE_AUTH_SOCK="${SSH_AUTH_SOCK}"
|
||||
export SSH_REMOTE_AUTH_SOCK
|
||||
# Always update the symlink to the latest session's socket.
|
||||
# This ensures that tmux (which uses the static path) always points to a
|
||||
# This ensures that tmux (which uses the static path) always points to a
|
||||
# current agent.
|
||||
mkdir -p "$(dirname "${REMOTE_LINK}")"
|
||||
ln -sf "${SSH_AUTH_SOCK}" "${REMOTE_LINK}"
|
||||
SSH_AUTH_SOCK="${REMOTE_LINK}"
|
||||
export SSH_AUTH_SOCK
|
||||
fi
|
||||
|
||||
# if stdin is a tty, don't do the cookie step
|
||||
|
||||
@@ -45,7 +45,7 @@ set -g window-status-current-style fg=colour235,bg=colour33,bold
|
||||
set -g status-interval 60
|
||||
set -g status-left-length 30
|
||||
set -g status-left '/#h: #S/ '
|
||||
set -g status-right '#{?pane_title,/#{pane_title}/ ,}#(cut -d " " -f 1-3 /proc/loadavg)#[default] #[fg=colour166]%H:%M#[default]'
|
||||
set -g status-right '#{?pane_title,/#{pane_title}/ ,}#(uptime | rev | cut -d":" -f1 | rev | sed s/,//g)#[default] #[fg=colour166]%H:%M#[default]'
|
||||
|
||||
# Advanced mouse mode from http://tangledhelix.com/blog/2012/07/16/tmux-and-mouse-mode/
|
||||
# Toggle mouse on
|
||||
@@ -65,8 +65,9 @@ bind M \
|
||||
display 'Mouse: OFF'
|
||||
|
||||
# tmux X clipboard integration
|
||||
bind C-c run "tmux show-buffer | xsel -i -b"
|
||||
bind C-v run "tmux set-buffer -- \"$(xsel -o -b)\"; tmux paste-buffer"
|
||||
if-shell 'test "$(uname)" = "Darwin"' \
|
||||
'bind C-c run "tmux show-buffer | pbcopy"; bind C-v run "tmux set-buffer -- \"$(pbpaste)\"; tmux paste-buffer"' \
|
||||
'bind C-c run "tmux show-buffer | xsel -i -b"; bind C-v run "tmux set-buffer -- \"$(xsel -o -b)\"; tmux paste-buffer"'
|
||||
|
||||
# List of plugins
|
||||
set -g @plugin 'tmux-plugins/tpm'
|
||||
|
||||
@@ -289,6 +289,8 @@ fi
|
||||
PATH="${HOME}/bin:${PATH}"
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
PATH="${HOME}/bin/macos:${PATH}"
|
||||
elif [[ "$(uname)" == "Linux" ]]; then
|
||||
PATH="${HOME}/bin/linux:${PATH}"
|
||||
fi
|
||||
|
||||
# Load any local settings
|
||||
|
||||
@@ -18,8 +18,15 @@ alert() {
|
||||
icon="error"
|
||||
fi
|
||||
|
||||
# Send the notification with the executed command
|
||||
notify-send --urgency=low -i "$icon" "Finished: '$@'"
|
||||
if [ "$(uname)" = "Darwin" ]; then
|
||||
# macOS notification
|
||||
local title="Finished: '$*'"
|
||||
local msg="Exit code: $ret"
|
||||
osascript -e "display notification \"$msg\" with title \"$title\""
|
||||
else
|
||||
# Send the notification with the executed command
|
||||
notify-send --urgency=low -i "$icon" "Finished: '$@'"
|
||||
fi
|
||||
|
||||
# Return the original exit code
|
||||
return $ret
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
ANDROID_HOME=$HOME/Library/Android/sdk
|
||||
if [ "$(uname)" = "Darwin" ]; then
|
||||
ANDROID_HOME=$HOME/Library/Android/sdk
|
||||
else
|
||||
ANDROID_HOME=$HOME/Android/Sdk
|
||||
fi
|
||||
|
||||
if test -d $ANDROID_HOME ; then
|
||||
PATH=$PATH:$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools
|
||||
if test -d "${ANDROID_HOME}" ; then
|
||||
export ANDROID_HOME
|
||||
PATH="${PATH}:${ANDROID_HOME}/emulator:${ANDROID_HOME}/platform-tools"
|
||||
else
|
||||
unset ANDROID_HOME
|
||||
fi
|
||||
|
||||
@@ -6,7 +6,11 @@ if have_command nasm && have_command objdump ; then
|
||||
local TMPF=`mktemp`
|
||||
local bytes
|
||||
local byte
|
||||
$NASM -f elf -o $TMPF $1
|
||||
local format="elf"
|
||||
if [[ "$OSTYPE" == darwin* ]]; then
|
||||
format="macho64"
|
||||
fi
|
||||
$NASM -f $format -o $TMPF $1
|
||||
$OBJDUMP -M intel -d $TMPF | grep '^ ' | cut -f2 | while read -A bytes ; do
|
||||
for byte in $bytes ; do
|
||||
echo -n "\\\\x$byte"
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
function dumpenv {
|
||||
tr '\0' '\n' < /proc/${1}/environ
|
||||
if [ "$(uname)" = "Linux" ]; then
|
||||
tr '\0' '\n' < /proc/${1}/environ
|
||||
elif [ "$(uname)" = "Darwin" ]; then
|
||||
# macOS doesn't have /proc, use ps instead.
|
||||
# Note: this may truncate if environment is very large.
|
||||
ps -p ${1} -wwwe -o command= | tr ' ' '\n' | grep '='
|
||||
fi
|
||||
}
|
||||
|
||||
if test -x "/sbin/starship" ; then
|
||||
|
||||
@@ -1,8 +1,20 @@
|
||||
test -f /usr/share/source-highlight/src-hilite-lesspipe.sh && \
|
||||
# Find src-hilite-lesspipe.sh
|
||||
_SRCHILITE=""
|
||||
for _p in /usr/share/source-highlight/src-hilite-lesspipe.sh /opt/homebrew/bin/src-hilite-lesspipe.sh /usr/local/bin/src-hilite-lesspipe.sh ; do
|
||||
if [ -f "$_p" ] ; then
|
||||
_SRCHILITE="$_p"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$_SRCHILITE" ] ; then
|
||||
function srcless {
|
||||
if [ $# -ne 1 ] ; then
|
||||
echo "$0 <what>" > /dev/stderr
|
||||
echo "Usage: srcless <file>" > /dev/stderr
|
||||
return 1
|
||||
fi
|
||||
/usr/share/source-highlight/src-hilite-lesspipe.sh $1 | less -R
|
||||
"$_SRCHILITE" "$1" | less -R
|
||||
}
|
||||
fi
|
||||
|
||||
unset _SRCHILITE _p
|
||||
|
||||
56
dotfiles/zshrc.d/util.zsh
Normal file
56
dotfiles/zshrc.d/util.zsh
Normal file
@@ -0,0 +1,56 @@
|
||||
# utility function to "open" a file
|
||||
o() {
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
open "$@"
|
||||
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
xdg-open "$@"
|
||||
else
|
||||
echo "Unknown OS"
|
||||
fi
|
||||
}
|
||||
|
||||
# Copy from stdin to the system clipboard
|
||||
syscopy() {
|
||||
if command -v pbcopy >/dev/null 2>&1; then
|
||||
# macOS
|
||||
pbcopy "$@"
|
||||
elif command -v wl-copy >/dev/null 2>&1; then
|
||||
# Linux Wayland
|
||||
wl-copy "$@"
|
||||
elif command -v xclip >/dev/null 2>&1; then
|
||||
# Linux X11
|
||||
xclip -selection clipboard "$@"
|
||||
elif command -v xsel >/dev/null 2>&1; then
|
||||
# Linux X11 (alternative)
|
||||
xsel --clipboard --input "$@"
|
||||
elif command -v clip.exe >/dev/null 2>&1; then
|
||||
# Windows WSL
|
||||
clip.exe "$@"
|
||||
else
|
||||
echo "Error: No clipboard utility found. Please install pbcopy, wl-copy, xclip, or xsel." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Paste from the system clipboard to stdout
|
||||
syspaste() {
|
||||
if command -v pbpaste >/dev/null 2>&1; then
|
||||
# macOS
|
||||
pbpaste "$@"
|
||||
elif command -v wl-paste >/dev/null 2>&1; then
|
||||
# Linux Wayland
|
||||
wl-paste "$@"
|
||||
elif command -v xclip >/dev/null 2>&1; then
|
||||
# Linux X11
|
||||
xclip -selection clipboard -o "$@"
|
||||
elif command -v xsel >/dev/null 2>&1; then
|
||||
# Linux X11 (alternative)
|
||||
xsel --clipboard --output "$@"
|
||||
elif command -v powershell.exe >/dev/null 2>&1; then
|
||||
# Windows WSL
|
||||
powershell.exe -noprofile -command Get-Clipboard "$@"
|
||||
else
|
||||
echo "Error: No clipboard utility found. Please install pbpaste, wl-paste, xclip, or xsel." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user