Adds better pbcopy and pbpaste aliases. Reorganizes .gitconfig.
This commit is contained in:
@@ -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`
|
||||
|
||||
Reference in New Issue
Block a user