dotfiles/executable_dot_aliasrc
2024-07-02 20:42:51 -04:00

141 lines
3.5 KiB
Bash

#!/bin/sh
lf () {
# `command` is needed in case `lfcd` is aliased to `lf`
cd "$(command lf -print-last-dir "$@")"
}
load_aliases() {
local TIMEFMT='\%J\n%mE:'
local OLDPATH=$PATH
# local SUDO=/bin/sudo
PATH=$(echo "$PATH" | sed -e 's/\/mnt\/.*\?://g')
if command -v type >/dev/null 2>&1; then
CHECK=type
else
CHECK='command -v'
fi
checkCommand() {
"$CHECK" "$1" >/dev/null 2>&1
}
# make a directory and cd to it
mcd()
{
test -d "$1" || mkdir -p "$1" && cd "$1"
}
# Put wget hsts file in XDG dir
alias wget=wget --hsts-file="$XDG_DATA_HOME/wget-hsts"
# Utilities for managing git and docker
alias lg='lazygit'
alias lzd='lazydocker'
# for static compilation of go binaries
alias musl-go="GOBIN=$HOME/bin CGO_ENABLED=1 CC=musl-gcc go install --ldflags '-linkmode external -extldflags=-static'"
# Replace df with duf
if checkCommand duf; then
alias df="dfrs"
fi
# Replace diff with delta
if checkCommand delta; then
alias diff="delta"
fi
# replaces gnu coreutils with the rust versions, cp and mv are worth
# if checkCommand coreutils; then
# alias cp="coreutils cp -g"
# alias mv="coreutils mv -g"
# alias hashsum="coreutils hashsum"
# #alias more="coreutils more"
# alias cut="coreutils cut"
# alias chmod="coreutils chmod"
# alias chown="coreutils chown"
# alias chroot="coreutils chroot"
# alias echo="coreutils echo"
# alias head="coreutils head"
# alias kill="coreutils kill"
# alias ln="coreutils ln"
# alias mkdir="coreutils mkdir"
# alias nohup="coreutils nohup"
# alias tail="coreutils tail"
# fi
# Replace find with fd
if checkCommand fd; then
alias find="fd"
fi
if checkCommand fdfind; then
alias find="fdfind"
fi
# Replace du with gdu
if checkCommand gdu; then
alias du="gdu"
alias ncdu="gdu"
fi
# Replace watch with viddy
if checkCommand viddy; then
alias watch="viddy"
fi
# Replace cat with bat
if checkCommand bat; then
alias cat="bat"
alias batlog="bat --paging=never -l log"
alias battail="tail -f | bat --paging=never -l log"
fi
# Replace tree with broot
if checkCommand tree; then
alias tree="broot"
fi
# Replace gping with ping
if checkCommand gping; then
alias ping="gping"
fi
# replace vim with neovim (this is probably done automatically usually)
if checkCommand nvim; then
alias vim="nvim"
fi
# Replace ls with lsd, and other useful aliases
if checkCommand lsd; then
alias l="lsd -l"
alias ls="lsd"
alias la="lsd -laa"
alias ll="lsd -la"
else
alias l="ls -lF -v --color=auto"
alias ls="ls -vF --color=auto"
alias la="ls -laF -v --color=auto"
alias ll="ls -lhAF -v --color=auto"
fi
PATH=$OLDPATH
unset OLDPATH
if checkCommand nala; then
alias apt="nala"
# sudo() {
# if [ "$1" = "apt" ]; then
# shift
# $SUDO nala "$@"
# else
# $SUDO "$@"
# fi
# }
fi
if checkCommand swhkd; then
alias reload-swhkd="sudo pkill -HUP swhkd"
fi
alias icat="kitty +kitten icat"
}
load_aliases
unset -f load_aliases