2020-04-21 12:39:18 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-12-17 17:32:55 -05:00
|
|
|
if command -v yay &> /dev/null; then
|
2023-12-17 17:31:46 -05:00
|
|
|
alias pacman="yay"
|
|
|
|
fi
|
|
|
|
|
2023-12-13 15:00:04 -05:00
|
|
|
function ishelp {
|
|
|
|
[[ "$1" == "help" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]
|
|
|
|
}
|
|
|
|
|
|
|
|
function stv {
|
|
|
|
local stash=0
|
|
|
|
if ishelp $1; then
|
|
|
|
echo "Show the diff for the given stash. Default to 0"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
if [[ "${1:0:1}" == "^" ]]; then
|
|
|
|
stash=${#1}
|
|
|
|
elif [[ "$1" != "" ]]; then
|
|
|
|
stash="$1"
|
|
|
|
fi
|
|
|
|
git stash show -p stash@{$stash}
|
|
|
|
}
|
|
|
|
|
2023-09-27 12:21:12 -04:00
|
|
|
function hearch {
|
|
|
|
history 0 | sed 's/[0-9 ]*//' | grep "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
alias hsearch='hearch'
|
|
|
|
|
2023-12-13 13:42:44 -05:00
|
|
|
alias caddyfile="sudo vim /etc/caddy/Caddyfile"
|
|
|
|
alias cf="sudo vim /etc/caddy/Caddyfile"
|
|
|
|
|
|
|
|
function download-channel {
|
|
|
|
~/Downloads/yt-dlp "$1" --format 'bestvideo[height=1080]+bestaudio/best' --download-archive archive.txt --output '%(uploader)s/%(upload_date)s.%(title)s.%(id)s.%(ext)s' --restrict-filenames --merge-output-format mkv --ignore-errors
|
|
|
|
}
|
|
|
|
|
2021-07-09 16:56:51 -04:00
|
|
|
function fin {
|
|
|
|
find -iname "*$@*"
|
|
|
|
}
|
|
|
|
|
2023-12-16 12:20:25 -05:00
|
|
|
function scpace {
|
|
|
|
scp -P 11275 $@
|
|
|
|
}
|
|
|
|
|
2023-08-26 00:09:09 -04:00
|
|
|
function gamp {
|
|
|
|
git add * && git commit -am "$1" && git push
|
|
|
|
}
|
|
|
|
|
|
|
|
function gap {
|
|
|
|
git add * && git commit -a && git push
|
|
|
|
}
|
|
|
|
|
|
|
|
function gd {
|
|
|
|
git add * && git diff --cached --word-diff=porcelain
|
|
|
|
}
|
|
|
|
|
2022-01-30 23:12:32 -05:00
|
|
|
function wf {
|
2022-01-30 22:42:56 -05:00
|
|
|
if [[ "$@" != "" ]]; then
|
|
|
|
local fzf_args="-q $@"
|
|
|
|
fi
|
2022-02-01 00:23:02 -05:00
|
|
|
echo ~/wiki/"$(rg --with-filename --no-heading . ~/wiki | sed 's@/home/sage/wiki/@@' | fzf -i $fzf_args -1 --preview='bat ~/wiki/$(echo {} | sed "s/:.*//")' | sed 's/:.*//')"
|
2022-01-30 23:12:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function ws {
|
|
|
|
local filename="$(wf $@)"
|
2022-01-30 22:42:56 -05:00
|
|
|
if [[ "$filename" != "" ]]; then
|
2022-01-30 23:12:32 -05:00
|
|
|
vim $filename
|
2022-01-30 22:42:56 -05:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function ww {
|
2022-02-01 00:23:02 -05:00
|
|
|
ws $(rg --no-line-number --no-filename . ~/wiki | sed 's/[^a-zA-Z0-9]\+/\n/g' | grep -v "^$" | sort -f | uniq -ci | sort -hr | fzf -i | cut -c 9-)
|
2022-01-30 22:42:56 -05:00
|
|
|
}
|
|
|
|
|
2023-12-13 16:04:46 -05:00
|
|
|
if command -v bat &> /dev/null; then
|
2023-12-13 12:21:25 -05:00
|
|
|
alias cat="bat -p"
|
2022-10-17 22:39:26 -04:00
|
|
|
fi
|
2021-10-06 13:23:45 -04:00
|
|
|
export FZF_DEFAULT_COMMAND='fd --type f'
|
|
|
|
alias fzf="fzf --preview 'bat --style=numbers --color=always {}'"
|
|
|
|
|
|
|
|
function vo {
|
|
|
|
if [[ "$1" == "" ]]; then
|
|
|
|
local f="$(fzf --preview "bat --style=numbers --color=always {}")"
|
|
|
|
if [[ "$f" != "" ]]; then
|
|
|
|
print -s "vim $f"
|
|
|
|
vim $f
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
local f="$(fzf -1 -q $@ | head -n 1)"
|
|
|
|
if [[ "$f" != "" ]]; then
|
|
|
|
print -s "vim $f"
|
|
|
|
vim $f
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo $f
|
|
|
|
}
|
|
|
|
|
2023-08-26 00:09:09 -04:00
|
|
|
alias yt='yt-dlp'
|
|
|
|
function y {
|
|
|
|
cd ~/.ytdl; yt-dlp $@; cd -
|
|
|
|
}
|
|
|
|
|
2021-07-09 16:56:51 -04:00
|
|
|
# Mkdir should remind you to use git
|
|
|
|
alias mkdir="echo 'Maybe use git init if this is a new project' && mkdir"
|
|
|
|
|
2020-04-21 12:39:18 -04:00
|
|
|
# Use `al` to view and edit aliases
|
2020-04-21 15:31:35 -04:00
|
|
|
alias al="vim ~/.shell_aliases && source ~/.shell_aliases && pushdot"
|
2020-04-21 12:39:18 -04:00
|
|
|
|
|
|
|
# Sudo commands will turn red
|
|
|
|
alias sudo='echo -e "\e[1;31m" && sudo'
|
|
|
|
|
2020-04-22 14:23:42 -04:00
|
|
|
alias clip="xclip -selection clipboard"
|
|
|
|
|
2020-04-21 14:31:55 -04:00
|
|
|
alias cim="vim"
|
2020-04-21 12:39:18 -04:00
|
|
|
|
|
|
|
# Use `vimc` to edit ~/.vimrc
|
2020-04-21 15:31:35 -04:00
|
|
|
alias vimc="vim ~/.vimrc && pushdot"
|
|
|
|
alias cimc="vim ~/.vimrc && pushdot"
|
2021-07-09 16:56:51 -04:00
|
|
|
|
|
|
|
# Resume session
|
2020-04-21 15:31:35 -04:00
|
|
|
alias vims="vim -S *.vims"
|
2020-04-21 12:39:18 -04:00
|
|
|
|
|
|
|
# Use `zz` to edit ~/.zshrc
|
2020-04-21 15:31:35 -04:00
|
|
|
alias zz='vim ~/.zshrc && source ~/.zshrc && pushdot'
|
2020-04-21 12:39:18 -04:00
|
|
|
alias termrc='vim ~/.config/xfce4/terminal/terminalrc'
|
|
|
|
|
|
|
|
# Use `grepr` for a recursive, case-insensitive, and filtered grep
|
|
|
|
# alias grepr="grep -RInsi --color=auto --exclude-dir=.git --exclude=tags"
|
|
|
|
# alias grepr='grep -RInsi --color=auto --exclude-dir=.git --exclude-dir=banana_pi_kernel --exclude-dir={bpi_build_scripts, storm_dox, sam_dox} --exclude=tags --exclude=\*.{ko, o}'
|
2023-09-27 12:21:12 -04:00
|
|
|
alias grepr='grep -RIns --color=auto --exclude-dir=.git --exclude-dir=venv --exclude-dir=node_modules --exclude=tags --exclude-dir=build --exclude-dir=.idea'
|
2021-10-06 13:23:45 -04:00
|
|
|
alias grepi='grepr -i'
|
2020-04-21 12:39:18 -04:00
|
|
|
|
|
|
|
alias apt="sudo apt"
|
|
|
|
alias apt-get="sudo apt-get"
|
|
|
|
alias eject="sudo eject"
|
|
|
|
alias dpkg="sudo dpkg"
|
|
|
|
alias dpi="sudo dpkg -i"
|
2020-04-23 11:44:34 -04:00
|
|
|
alias pacman="sudo pacman"
|
|
|
|
alias systemctl="sudo systemctl"
|
2020-04-21 12:39:18 -04:00
|
|
|
|
|
|
|
alias python="python3"
|
2020-04-30 13:37:24 -04:00
|
|
|
alias py="python3"
|
2020-04-21 12:39:18 -04:00
|
|
|
|
|
|
|
# Use `grubdate` to update grub
|
|
|
|
alias grubdate="sudo update-grub"
|
|
|
|
|
|
|
|
# Use `open` after `grepr` to vim a file with grep text matching $1
|
|
|
|
alias open=_open
|
|
|
|
alias open2=_open2
|
|
|
|
|
|
|
|
# `pp` and `pwoeroff` -> `poweroff`
|
|
|
|
alias pp=poweroff
|
|
|
|
alias pwoeroff=poweroff
|
|
|
|
|
2020-05-01 14:55:39 -04:00
|
|
|
# Use `ll` to get a detailed list of files, sorted by size
|
2020-05-01 14:57:03 -04:00
|
|
|
alias ll='ls --color=auto -FlrSh -w 80'
|
2020-04-21 12:39:18 -04:00
|
|
|
alias ls='ls --color=auto -F -w 80'
|
|
|
|
|
2020-05-01 14:53:21 -04:00
|
|
|
# Using du automatically finds the total
|
|
|
|
alias du='du -sh'
|
|
|
|
|
2021-10-06 13:23:45 -04:00
|
|
|
alias tags='ctags --exclude=node_modules -f newtags -R . && mv newtags tags'
|
2022-01-30 23:12:32 -05:00
|
|
|
|
|
|
|
if [[ "$@" != "" ]]; then
|
|
|
|
$@
|
|
|
|
fi
|