Adds better pbcopy and pbpaste aliases. Reorganizes .gitconfig.

This commit is contained in:
2025-11-14 15:22:48 -08:00
parent 104be6aa28
commit cbfe498009
3 changed files with 45 additions and 10 deletions

View File

@@ -2,7 +2,7 @@
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
## If not running interactively, don't do anything
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
@@ -79,6 +79,7 @@ esac
for f in ~/.rc.d/*.sh; do
source "$f"
done
# TODO: do the same for ~/.rc.d/*.bash to only do bash scripts or make the scripts figure out what shell they are under.
## Autocompletion

View File

@@ -1,10 +1,4 @@
[user]
name = Tom Hicks
email = headunter3@gmail.com
[core]
excludesfile = /Users/tom/.gitignore_global
[alias]
amend = commit --amend --no-edit
br = branch
brr = branch -r
co = checkout
@@ -16,7 +10,10 @@
rbs = !git checkout main && git pull && git checkout - && git rebase main
cop = "!f() { git checkout ${1-main}; git pull; }; f"
lazy = commit -C HEAD@{1}
[pull]
ff = only
[init]
defaultBranch = main
[pull]
ff = only
[user]
name = Tom Hicks
email = headhunter3@gmail.com

View File

@@ -1,3 +1,17 @@
# Helper: define alias only if command doesn't already exist
ensure_alias() {
local name="$1" cmd="$2"
if ! command -v "$name" >/dev/null 2>&1; then
alias "$name"="$cmd"
fi
}
# Detect WSL
is_wsl=false
if grep -qi microsoft /proc/version 2>/dev/null; then
is_wsl=true
fi
# TODO: detect color support and enable/disable color in aliases based on that.
# File Manipulation
# TODO: bash ls doesn't need -G or maybe macs don't. Figure that out and use that test here.
@@ -58,6 +72,29 @@ alias tea='tee -a'
alias find_recent='function { find . $* -exec ls -ltr {} + }'
alias find_recent='function f() { find . $* -exec ls -ltr {} + ; unset -f f; }; f'
# pbcopy
if ! command -v pbcopy >/dev/null 2>&1; then
if command -v wl-copy >/dev/null 2>&1; then
ensure_alias pbcopy 'wl-copy'
elif command -v xclip >/dev/null 2>&1; then
ensure_alias pbcopy 'xclip -selection clipboard'
elif [ "$is_wsl" = true ] && command -v clip.exe >/dev/null 2>&1; then
ensure_alias pbcopy 'clip.exe'
fi
fi
# pbpaste
if ! command -v pbpaste >/dev/null 2>&1; then
if command -v wl-paste >/dev/null 2>&1; then
ensure_alias pbpaste 'wl-paste'
elif command -v xclip >/dev/null 2>&1; then
ensure_alias pbpaste 'xclip -selection clipboard -o'
elif [ "$is_wsl" = true ] && command -v powershell.exe >/dev/null 2>&1; then
ensure_alias pbpaste 'powershell.exe -noprofile Get-Clipboard'
fi
fi
# In Development
# Dosn't work if command is piped e.g. `log_and_do "ls | tee out.txt" my_other_file.txt`