Marty Oehme
179840e4c0
Added alias `vw` to open the index page of my PKB (essentially the start page of my wiki) using my zettelkasten.nvim plugin.
115 lines
2.9 KiB
Bash
115 lines
2.9 KiB
Bash
#!/usr/bin/env sh
|
|
#
|
|
# Global aliases for any shell
|
|
|
|
exist() { type "$1" >/dev/null 2>&1; }
|
|
|
|
# Avoid aliases which I did not create -- unalias EVERYTHING
|
|
unalias -a
|
|
|
|
# v shorthand for neovim
|
|
if exist nvim; then
|
|
alias v="nvim"
|
|
alias vim="nvim"
|
|
alias vs="nvim -c 'ScratchPad'" # open an empty 'scratchpad' which simply disappears after use
|
|
alias vw="nvim -c \"lua require 'zettelkasten'.index_open()\"" # open to personal wiki
|
|
elif exist vim; then
|
|
alias v="vim"
|
|
else
|
|
alias v="vi"
|
|
alias vim="vi"
|
|
fi
|
|
|
|
# exit shell mimicks vim
|
|
alias :q="exit"
|
|
|
|
# ls defaults
|
|
if exist exa; then
|
|
alias l="exa -l --git --git-ignore --group-directories-first"
|
|
alias L="exa -hal --grid --git --group-directories-first"
|
|
# a recursive tree
|
|
# - usually want to change levels recursed with -L2 -L3 or similar
|
|
alias ll="exa --tree -L2 --group-directories-first"
|
|
alias LL="exa -a --tree -L2 --group-directories-first"
|
|
else
|
|
alias l="ls -lhF"
|
|
alias L="ls -lAhF"
|
|
fi
|
|
|
|
# cd defaults
|
|
alias ..="cd .."
|
|
alias ...="cd ../.."
|
|
alias ~="cd ~"
|
|
|
|
alias md="mkdir -p"
|
|
|
|
# clear my screen
|
|
alias cl="clear"
|
|
|
|
# Display current external ip address
|
|
alias myip="curl -s icanhazip.com"
|
|
|
|
# fzf
|
|
if exist fzf; then
|
|
# Display fuzzy-searchable history
|
|
alias fzfhistory="history -l -E -D 0 | fzf --tac --height 20"
|
|
fzfman() {
|
|
man "$(apropos --long "$1" | fzf | awk '{print $2, $1}' | tr -d '()')"
|
|
}
|
|
|
|
# Fuzzy search packages to install
|
|
if exist yay; then
|
|
fzf_pkg_tool=yay
|
|
elif exist paru; then
|
|
fzf_pkg_tool=paru
|
|
elif exist pacman; then
|
|
fzf_pkg_tool=pacman
|
|
fi
|
|
# shellcheck disable=2139 # we *want* this to be done at shell startup instead of dynamically
|
|
if [ -n "$fzf_pkg_tool" ]; then
|
|
alias fzfyay="$fzf_pkg_tool -Slq | fzf -m --preview '$fzf_pkg_tool -Si {1}' | xargs -ro $fzf_pkg_tool -S"
|
|
# Fuzzy uninstall packages
|
|
alias fzfyayrns="$fzf_pkg_tool -Qeq | fzf -m --preview '$fzf_pkg_tool -Qi {1}' | xargs -ro $fzf_pkg_tool -Rns"
|
|
fi
|
|
unset fzf_pkg_tool
|
|
|
|
# ripgrep-all to fzf search through any documents
|
|
if exist rga; then
|
|
fzfrga() {
|
|
RG_PREFIX="rga --files-with-matches"
|
|
xdg-open "$(
|
|
FZF_DEFAULT_COMMAND="$RG_PREFIX '$1'" \
|
|
fzf --sort --preview="[[ ! -z {} ]] && rga --pretty --context 5 {q} {}" \
|
|
--phony -q "$1" \
|
|
--bind "change:reload:$RG_PREFIX {q}" \
|
|
--preview-window="70%:wrap"
|
|
)"
|
|
}
|
|
fi
|
|
fi
|
|
|
|
# vifm
|
|
if exist vifm; then
|
|
alias vm=vifm
|
|
alias vmm='vifm ${PWD}'
|
|
fi
|
|
|
|
# nsxiv image viewer
|
|
if exist nsxiv; then
|
|
if exist nsxiv-rifle; then
|
|
alias iv=nsxiv-rifle
|
|
else
|
|
alias iv=nsxiv
|
|
fi
|
|
elif exist sxiv; then
|
|
alias iv=sxiv
|
|
fi
|
|
|
|
# python
|
|
if exist ptipython; then
|
|
alias py=ptipython
|
|
elif exist ipython; then
|
|
alias py=ipython
|
|
elif exist python; then
|
|
alias py=python
|
|
fi
|