274 lines
7 KiB
Text
274 lines
7 KiB
Text
# ~/dotfiles/aliases.sh
|
|
|
|
# ---- 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
|
|
|
|
# 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 c='clear'
|
|
alias d=docker
|
|
alias dc=docker-compose
|
|
# alias h='history'
|
|
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 p='parallel'
|
|
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 {1} --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
|
|
}
|
|
|
|
# ----------------------------
|
|
# File & Disk Utilities
|
|
# ----------------------------
|
|
|
|
alias batclip='bat $1 | xclip'
|
|
alias du='dust'
|
|
alias dfh='gdu -dn'
|
|
alias 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'
|
|
# 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='command -v | 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'
|
|
|
|
|
|
# ----------------------------
|
|
# 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
|
|
}
|
|
|
|
# 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'
|
|
fi
|
|
|
|
if command -v ag &> /dev/null; then
|
|
alias ags='ag --smart-case'
|
|
alias agf='ag -l | fzf'
|
|
fi
|
|
|
|
if command -v atuin &> /dev/null; then
|
|
alias h='atuin'
|
|
else
|
|
alias h='history | fzf'
|
|
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}')
|
|
}
|