400 lines
11 KiB
Text
400 lines
11 KiB
Text
# ~/dotfiles/aliases.sh
|
|
|
|
# ---- PAI Commands -----
|
|
alias cmd='bun ~/.claude/commands/cmd.ts'
|
|
|
|
# ---- Fabric -----
|
|
|
|
yt() {
|
|
if [[ "$#" -eq 0 ]] || [[ "$#" -gt 2 ]]; then
|
|
echo "Usage: yt [[-t | --timestamps]] youtube-link"
|
|
echo "Use the '-t' flag to get the transcript with timestamps."
|
|
return 1
|
|
fi
|
|
|
|
transcript_flag="--transcript"
|
|
if [[ "$1" = "-t" ]] || [[ "$1" = "--timestamps" ]]; then
|
|
transcript_flag="--transcript-with-timestamps"
|
|
shift
|
|
fi
|
|
local video_link="$1"
|
|
fabric -y "$video_link" $transcript_flag
|
|
}
|
|
|
|
for pattern_file in "$HOME"/.config/fabric/patterns/*; do
|
|
# Get the base name of the file (i.e., remove the directory path)
|
|
pattern_name=$(basename "$pattern_file")
|
|
# Create an alias in the form: alias pattern_name="fabric --pattern pattern_name"
|
|
alias_command="alias $pattern_name='fabric --pattern $pattern_name'"
|
|
# Evaluate the alias command to add it to the current shell
|
|
eval "$alias_command"
|
|
done
|
|
|
|
# --- OpenCode ---
|
|
|
|
ide() {
|
|
local project="${1:-$(pwd)}" # directory to open, pwd if not specified
|
|
local editor="${2:-hx}" # default helix
|
|
local win_name="ide"
|
|
|
|
if [[ -n "$TMUX" ]]; then
|
|
tmux new-window -n "$win_name" -c "$project"
|
|
|
|
# Left pane: opencode
|
|
tmux select-pane -t 0
|
|
tmux send-keys "opencode" C-m
|
|
|
|
# Split right: right side gets 75%, left remains 25%
|
|
tmux split-window -h -p 75 -c "$project" # pane 1 (right)
|
|
tmux send-keys "$editor \"$project\"" C-m
|
|
|
|
# Now on right side, split horizontally for bottom editor (~25%)
|
|
tmux select-pane -t 1
|
|
|
|
# Bottom-right: editor
|
|
tmux select-pane -t 2
|
|
tmux split-window -v -p 25 -c "$project" # pane 2 (bottom-right)
|
|
|
|
# Focus back on top-right (main terminal)
|
|
tmux select-pane -t 1
|
|
else
|
|
tmux new-session -s "$win_name" -n main -d -c "$project"
|
|
tmux split-window -h -p 75 -c "$project"
|
|
tmux select-pane -t 0
|
|
tmux send-keys "opencode" C-m
|
|
tmux select-pane -t 1
|
|
tmux split-window -v -p 25 -c "$project"
|
|
tmux select-pane -t 2
|
|
tmux send-keys "$editor \"$project\"" C-m
|
|
tmux select-pane -t 1
|
|
tmux attach -t "$win_name"
|
|
fi
|
|
}
|
|
|
|
|
|
# TMUX-RECON Aliases
|
|
|
|
# ----------------------------
|
|
# Clipboard (conditional on xsel or xclip)
|
|
# ----------------------------
|
|
|
|
if command -v xsel &> /dev/null; then
|
|
alias pbcopy='xsel --input --clipboard'
|
|
alias pbpaste='xsel --output --clipboard'
|
|
elif command -v xclip &> /dev/null; then
|
|
alias pbcopy='xclip -selection clipboard'
|
|
alias pbpaste='xclip -selection clipboard -o'
|
|
fi
|
|
|
|
|
|
# ----------------------------
|
|
# Basic Shortcuts
|
|
# ----------------------------
|
|
|
|
alias a='~/arsenal/run -t'
|
|
alias any='~/AnythingLLMDesktop/start'
|
|
alias c='clear'
|
|
cpy() {
|
|
cat "$1" | pbcopy
|
|
}
|
|
alias d='docker'
|
|
alias dc='docker-compose'
|
|
# alias h='history'
|
|
alias f='fabric'
|
|
#f() {
|
|
# fd "$1" -exec bat {} +
|
|
#}
|
|
alias i='sudo apt install'
|
|
alias j='journalctl -f'
|
|
alias jj='pbpaste | jsonpp | pbcopy'
|
|
alias jjj='pbpaste | jsonpp'
|
|
alias k='kill $(ps aux | fzf | awk '\''{print $2}'\'')'
|
|
# alias k9='kill -9 **'
|
|
alias nf='fzf -m --preview="bat --color=always --style=numbers --line-range:300 {}" --bind "enter:become(hx {+})"'
|
|
alias oc='opencode'
|
|
alias p='parallel'
|
|
|
|
alias rec='parecord --device=alsa_output.pci-0000_00_1f.3.analog-stereo.monitor \
|
|
--file-format=wav ~/recordings/meeting-$(date +%Y%m%d-%H%M%S).wav'
|
|
alias rm='rm -I'
|
|
|
|
if [[ -n "$ZSH_VERSION" ]]; then
|
|
alias s='source ~/.zshrc; source ~/.aliases'
|
|
elif [[ -n "$BASH_VERSION" ]]; then
|
|
alias s='source ~/.bashrc; source ~/.aliases'
|
|
fi
|
|
|
|
alias ta='tmux attach -t'
|
|
alias trim="awk '{\$1=\$1;print}'"
|
|
alias up='sudo apt update && sudo apt upgrade -y'
|
|
alias v='fd --type f --hidden --exclude .git | fzf-tmux -p --reverse | xargs hx'
|
|
alias vp='fd --type f --hidden --exclude .git | fzf --preview "bat {} --color=always --style=numbers" | xargs hx'
|
|
alias vv='hx $(fzf --preview="bat {} --color=always")'
|
|
alias gr='glow $(fzf --preview="bat {} --color=always")'
|
|
alias xx='exit'
|
|
alias eixt='exit'
|
|
alias yy='yazi'
|
|
|
|
|
|
# --------------------------------------
|
|
# Navigation
|
|
# --------------------------------------
|
|
|
|
# alias ..='cd ..'
|
|
# alias ...='cd ../..'
|
|
# alias cdf='cd $(fd -t d | fzf)'
|
|
# alias cdi='zoxide query -i'
|
|
|
|
function take {
|
|
mkdir -p "$1"
|
|
cd "$1" || exit
|
|
}
|
|
|
|
# ----------------------------
|
|
# File & Disk Utilities
|
|
# ----------------------------
|
|
|
|
# Unalias potential conflicts
|
|
unalias batclip 2>/dev/null
|
|
unalias dl 2>/dev/null
|
|
|
|
batclip() {
|
|
bat "$1" | xclip
|
|
}
|
|
alias du='dust'
|
|
alias dfh='gdu -dn'
|
|
dl() {
|
|
yt-dlp -f best "$1"
|
|
}
|
|
|
|
if [[ -n "$ZSH_VERSION" ]]; then
|
|
alias reload='source ~/.zshrc'
|
|
elif [[ -n "$BASH_VERSION" ]]; then
|
|
alias reload='source ~/.bashrc'
|
|
fi
|
|
|
|
|
|
tailb() {
|
|
tail -f "$1" | bat --paging=never -l log
|
|
}
|
|
|
|
|
|
# --------------------------------------
|
|
# Search / Fuzzy Finder
|
|
# --------------------------------------
|
|
|
|
# alias f='fd -H -I -t f'
|
|
# f() { cd "$(find . -type d | fzf)" }
|
|
alias fzf="fzf --preview 'bat --color=always {}'"
|
|
# alias fzf="fzf --height 40% --layout reverse --border --preview 'bat --color=always {}' --preview-window '~3'"
|
|
alias ff='find * -type f | fzf --preview "bat --color=always {}"'
|
|
# alias fd='fdfind' # Debian compatibility
|
|
|
|
# Press F1 to open the file with less without leaving fzf
|
|
# Press CTRL-Y to copy the line to clipboard and aborts fzf (requires pbcopy)
|
|
alias fo="fzf --bind 'f1:execute(less -f {}),ctrl-y:execute-silent(echo {} | pbcopy)+abort'"
|
|
|
|
alias psf="ps -ef |
|
|
fzf --bind 'ctrl-r:reload(ps -ef)' \
|
|
--header 'Press CTRL-R to reload' --header-lines=1 \
|
|
--height=50% --layout=reverse"
|
|
|
|
# List all commands or search through them
|
|
if [[ -n "$ZSH_VERSION" ]]; then
|
|
alias findcmd='print -l ${(k)commands} | fzf --prompt="Search command: "'
|
|
elif [[ -n "$BASH_VERSION" ]]; then
|
|
alias findcmd='compgen -c | sort -u | fzf --prompt="Search command: "'
|
|
fi
|
|
|
|
# alias findcmd='compgen -c | sort -u | fzf --prompt="Search command: "'
|
|
# alias allcmds='compgen -c | sort -u | fzf'
|
|
|
|
|
|
# ----------------------------
|
|
# Taskwarrior
|
|
# ----------------------------
|
|
|
|
alias t='task'
|
|
alias tl='task list'
|
|
alias twa='task add'
|
|
tm() {
|
|
task modify
|
|
}
|
|
alias tb='task burndown.daily'
|
|
|
|
# ----------------------------
|
|
# Miscellaneous
|
|
# ----------------------------
|
|
|
|
note() {
|
|
echo "date: $(date)" >> "$HOME"/drafts.txt
|
|
echo "$@" >> "$HOME"/drafts.txt
|
|
echo "" >> "$HOME"/drafts.txt
|
|
}
|
|
|
|
help() {
|
|
if builtin help "$1" &>/dev/null; then
|
|
builtin help "$1" | bat --plain
|
|
else
|
|
"$@" --help 2>&1 | bat --plain
|
|
fi
|
|
}
|
|
|
|
mdstrip() {
|
|
sed -i 's/\\n/\n/g' "$1"
|
|
}
|
|
|
|
|
|
# help() {
|
|
# "$@" --help 2>&1 | bat --plain --language=txt
|
|
# }
|
|
|
|
# alias shelp='builtin help | bat --plain --language=help'
|
|
|
|
# alias bathelp='bat --plain --language=help'
|
|
# help() {
|
|
# "$@" --help 2>&1 | bathelp
|
|
# }
|
|
|
|
# ----------------------------
|
|
# Conditional Fallbacks
|
|
# ----------------------------
|
|
|
|
# Debian-specific fix for fd
|
|
if ! command -v fd &> /dev/null && command -v fdfind &> /dev/null; then
|
|
alias fd='fdfind'
|
|
fi
|
|
|
|
# if command -v bat &> /dev/null; then
|
|
# alias cat="bat"
|
|
# elif command -v batcat &> /dev/null; then
|
|
# alias cat="batcat"
|
|
# fi
|
|
|
|
alias l='eza -lah --icons'
|
|
|
|
if command -v exa &> /dev/null; then
|
|
alias ls='exa'
|
|
# alias l='exa -l'
|
|
alias lsl='exa --icons'
|
|
alias ll='exa -lah --icons'
|
|
alias lt='exa -lah --tree --level=3 --icons'
|
|
fi
|
|
|
|
if command -v eza &> /dev/null; then
|
|
alias lg='eza -lah --icons --git -a'
|
|
fi
|
|
|
|
# Fallbacks if neither exa nor eza are found
|
|
if ! command -v exa &> /dev/null && ! command -v eza &> /dev/null; then
|
|
alias ls='ls --color=auto'
|
|
alias ll='ls -lah'
|
|
alias la='ls -A'
|
|
fi
|
|
|
|
if command -v rg &> /dev/null; then
|
|
alias rg='rg --smart-case'
|
|
alias rgl='rg --files | fzf --preview "bat --color=always {}"'
|
|
fi
|
|
|
|
if command -v ag &> /dev/null; then
|
|
alias ags='ag --smart-case'
|
|
alias agf='ag -l | fzf --preview "bat --color=always {}"'
|
|
fi
|
|
|
|
# Smart history with atuin (fallback to fzf if not available)
|
|
if command -v atuin &> /dev/null; then
|
|
alias h='atuin search --interactive'
|
|
else
|
|
alias h='history | fzf --preview "echo {}" --preview-window="up:3:wrap"'
|
|
fi
|
|
|
|
# Python as 'py' and pip
|
|
alias py='python3'
|
|
alias pip='python3 -m pip'
|
|
alias serve='python3 -m http.server 80'
|
|
|
|
# --------------------------------------
|
|
# Networking & System Info
|
|
# --------------------------------------
|
|
|
|
alias xh='xh --style auto'
|
|
alias myip='curl ifconfig.me'
|
|
alias localip="ip a | grep inet"
|
|
|
|
if command -v mtr &> /dev/null; then
|
|
alias ping='mtr'
|
|
else
|
|
unalias ping
|
|
fi
|
|
|
|
alias net='bandwhich'
|
|
alias sniff='sudo tcpdump -i any -n'
|
|
alias ports='ss -tuln'
|
|
alias psnet='sudo netstat -tulnp'
|
|
alias fire='sudo ufw status verbose'
|
|
alias logs='sudo tail -f /var/log/syslog'
|
|
alias chkports='sudo lsof -i -P -n | less'
|
|
|
|
# unalias zi
|
|
|
|
# GIT ALIASES -----------------------------------------------------------------
|
|
alias gc='git commit'
|
|
alias gco='git checkout'
|
|
alias ga='git add'
|
|
alias gst='git rev-parse --git-dir > /dev/null 2>&1 && git status || eza'
|
|
|
|
|
|
copy-line() {
|
|
rg --line-number . | fzf --delimiter ':' --preview 'bat --color=always --highlight-line {2} {1}' | awk -F ':' '{print "+"$2" "$1}'
|
|
}
|
|
|
|
open-at-line() {
|
|
hx $(rg --line-number . | fzf --delimiter ':' --preview 'bat --color=always --highlight-line {2} {1}' | awk -F ':' '{print "+"$2" "$1}')
|
|
}
|
|
|
|
# PAI Context Manager
|
|
alias cm="~/.claude/commands/context-manager.sh"
|
|
alias cms="~/.claude/commands/context-manager.sh search"
|
|
alias cmr="~/.claude/commands/context-manager.sh recent"
|
|
alias cmn="~/.claude/commands/context-manager.sh new"
|
|
alias cmt="~/.claude/commands/context-manager.sh tree"
|
|
|
|
# Enhanced fzf file operations with better previews
|
|
alias fzfg='rg --line-number --color=always . | fzf --ansi --delimiter ":" --preview "bat --color=always --highlight-line {2} {1}" --bind "enter:execute(hx +{2} {1})"'
|
|
alias fzfd='fd --type d | fzf --preview "eza --tree --level=2 --color=always {} 2>/dev/null || tree -L 2 -C {}"'
|
|
|
|
# Better process management
|
|
alias psg='ps aux | fzf --header-lines=1 --preview "echo {}" --preview-window=up:1'
|
|
|
|
# Enhanced git fzf integration
|
|
alias gfzf='git log --oneline --color=always | fzf --ansi --preview "git show --color=always {1}" --bind "enter:execute(git show {1} | less -R)"'
|
|
|
|
# --------------------------------------
|
|
# N8N API Helper
|
|
# --------------------------------------
|
|
# Requires N8N_API_KEY and N8N_BASE_URL in ~/.env
|
|
n8n_api() {
|
|
source ~/.env
|
|
local endpoint="${1:-/workflows}"
|
|
shift
|
|
curl -s -H "X-N8N-API-KEY: ${N8N_API_KEY}" \
|
|
"${N8N_BASE_URL}/api/v1${endpoint}" \
|
|
"$@"
|
|
}
|
|
|
|
# --------------------------------------
|
|
# Baserow API Helper
|
|
# --------------------------------------
|
|
# Requires BASEROW_API_KEY and BASEROW_TABLE_ID in ~/.env
|
|
# Baserow is on localhost:3000 via SSH tunnel
|
|
baserow_api() {
|
|
source ~/.env
|
|
local endpoint="${1:-database/rows/table/${BASEROW_CONTACTS_TABLE_ID}/}"
|
|
if [ $# -gt 0 ]; then
|
|
shift
|
|
fi
|
|
curl -s -H "Authorization: Token ${BASEROW_API_KEY}" \
|
|
"http://baserow:3000/api/${endpoint}" \
|
|
"$@"
|
|
}
|