2022-06-07 02:15:35 +00:00
|
|
|
## ____ __
|
|
|
|
## / __ \_________ _/ /_____
|
|
|
|
## / / / / ___/ __ `/ //_/ _ \
|
|
|
|
## / /_/ / / / /_/ / ,< / __/ Clay Gomera (Drake)
|
|
|
|
## /_____/_/ \__,_/_/|_|\___/ My custom bash config
|
|
|
|
##
|
|
|
|
|
|
|
|
### EXPORT ###
|
|
|
|
export TERM="xterm-256color" # getting proper colors
|
|
|
|
export HISTCONTROL=ignoredups:erasedups # no duplicate entries
|
2023-06-20 14:29:23 +00:00
|
|
|
export EDITOR="$HOME/.local/bin/lvim"
|
|
|
|
export VISUAL="wezterm start --class editor -- $HOME/.local/bin/lvim"
|
|
|
|
|
|
|
|
### "bat" as manpager
|
|
|
|
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
|
2022-06-07 02:15:35 +00:00
|
|
|
|
|
|
|
# use bash-completion, if available
|
|
|
|
[[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && \
|
|
|
|
. /usr/share/bash-completion/bash_completion
|
|
|
|
|
|
|
|
# if not running interactively, don't do anything
|
|
|
|
[[ $- != *i* ]] && return
|
|
|
|
|
|
|
|
# use neovim for vim if present.
|
2023-06-20 14:29:23 +00:00
|
|
|
[ -x "$(command -v $HOME/.local/bin/lvim)" ] && alias vim="lvim"
|
2022-06-07 02:15:35 +00:00
|
|
|
|
|
|
|
### SET VI MODE ###
|
|
|
|
# Comment this line out to enable default emacs-like bindings
|
|
|
|
set -o vi
|
|
|
|
bind -m vi-command 'Control-l: clear-screen'
|
|
|
|
bind -m vi-insert 'Control-l: clear-screen'
|
|
|
|
|
|
|
|
### PATH ###
|
|
|
|
if [ -d "$HOME/.bin" ] ;
|
|
|
|
then PATH="$HOME/.bin:$PATH"
|
|
|
|
fi
|
|
|
|
if [ -d "$HOME/.local/bin" ] ;
|
|
|
|
then PATH="$HOME/.local/bin:$PATH"
|
|
|
|
fi
|
|
|
|
if [ -d "$HOME/Applications" ] ;
|
|
|
|
then PATH="$HOME/Applications:$PATH"
|
|
|
|
fi
|
|
|
|
|
|
|
|
### CHANGE TITLE OF TERMINALS ###
|
|
|
|
case ${TERM} in
|
|
|
|
xterm*|rxvt*|Eterm*|aterm|kterm|gnome*|alacritty|st|konsole*)
|
|
|
|
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\007"'
|
|
|
|
;;
|
|
|
|
screen*)
|
|
|
|
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\033\\"'
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
### SHOPT ###
|
|
|
|
shopt -s autocd # change to named directory
|
|
|
|
shopt -s cdspell # autocorrects cd misspellings
|
|
|
|
shopt -s cmdhist # save multi-line commands in history as single line
|
|
|
|
shopt -s dotglob
|
|
|
|
shopt -s histappend # do not overwrite history
|
|
|
|
shopt -s expand_aliases # expand aliases
|
|
|
|
shopt -s checkwinsize # checks term size when bash regains control
|
|
|
|
|
|
|
|
# ignore upper and lowercase when TAB completion
|
|
|
|
bind "set completion-ignore-case on"
|
|
|
|
|
|
|
|
# sudo not required for some system commands
|
2022-07-16 18:29:15 +00:00
|
|
|
for command in cryptsetup mount umount poweroff reboot ; do
|
2022-06-07 02:15:35 +00:00
|
|
|
alias $command="sudo $command"
|
|
|
|
done; unset command
|
|
|
|
|
|
|
|
### ARCHIVE EXTRACTION ###
|
|
|
|
# usage: ex <file>
|
|
|
|
ex ()
|
|
|
|
{
|
|
|
|
if [ -f "$1" ] ; then
|
|
|
|
case $1 in
|
|
|
|
*.tar.bz2) tar xjf "$1" ;;
|
|
|
|
*.tar.gz) tar xzf "$1" ;;
|
|
|
|
*.bz2) bunzip2 "$1" ;;
|
|
|
|
*.rar) unrar x "$1" ;;
|
|
|
|
*.gz) gunzip "$1" ;;
|
|
|
|
*.tar) tar xf "$1" ;;
|
|
|
|
*.tbz2) tar xjf "$1" ;;
|
|
|
|
*.tgz) tar xzf "$1" ;;
|
|
|
|
*.zip) unzip "$1" ;;
|
|
|
|
*.Z) uncompress "$1";;
|
|
|
|
*.7z) 7zz x "$1" ;;
|
|
|
|
*.deb) ar x "$1" ;;
|
|
|
|
*.tar.xz) tar xf "$1" ;;
|
|
|
|
*.tar.zst) unzstd "$1" ;;
|
|
|
|
*) echo "'$1' cannot be extracted via ex()" ;;
|
|
|
|
esac
|
|
|
|
else
|
|
|
|
echo "'$1' is not a valid file"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
### ALIASES ###
|
|
|
|
# navigation
|
|
|
|
up () {
|
|
|
|
local d=""
|
|
|
|
local limit="$1"
|
|
|
|
|
|
|
|
# Default to limit of 1
|
|
|
|
if [ -z "$limit" ] || [ "$limit" -le 0 ]; then
|
|
|
|
limit=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
for ((i=1;i<=limit;i++)); do
|
|
|
|
d="../$d"
|
|
|
|
done
|
|
|
|
|
|
|
|
# perform cd. Show error if cd fails
|
|
|
|
if ! cd "$d"; then
|
|
|
|
echo "Couldn't go up $limit dirs.";
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# cd
|
|
|
|
alias \
|
|
|
|
..="cd .." \
|
|
|
|
.2="cd ../.." \
|
|
|
|
.3="cd ../../.." \
|
|
|
|
.4="cd ../../../.." \
|
|
|
|
.5="cd ../../../../.."
|
|
|
|
|
|
|
|
# bat as cat
|
|
|
|
[ -x "$(command -v bat)" ] && alias cat="bat"
|
|
|
|
|
2023-06-20 14:29:23 +00:00
|
|
|
# pfetch as neofetch
|
|
|
|
[ -x "$(command -v pfetch)" ] && alias neofetch="pfetch"
|
|
|
|
|
2022-06-07 02:15:35 +00:00
|
|
|
# Changing "ls" to "exa"
|
|
|
|
alias \
|
2023-02-20 00:41:01 +00:00
|
|
|
ls="exa -al --icons --color=always --group-directories-first" \
|
|
|
|
la="exa -a --icons --color=always --group-directories-first" \
|
|
|
|
ll="exa -l --icons --color=always --group-directories-first" \
|
|
|
|
lt="exa -aT --icons --color=always --group-directories-first" \
|
|
|
|
l.='exa -a | grep -E "^\."'
|
2022-06-07 02:15:35 +00:00
|
|
|
|
2023-06-20 14:29:23 +00:00
|
|
|
# pacman
|
2022-11-30 17:31:15 +00:00
|
|
|
alias \
|
2023-06-20 14:29:23 +00:00
|
|
|
pac-up="paru -Syu" \
|
2022-11-30 17:31:15 +00:00
|
|
|
pac-get="paru -S" \
|
|
|
|
pac-rmv="paru -Rcns" \
|
|
|
|
pac-rmv-sec="paru -R" \
|
|
|
|
pac-qry="paru -Ss" \
|
2023-06-20 14:29:23 +00:00
|
|
|
pac-cln="paru -Scc && sudo pacman -Rns $(pacman -Qtdq)"
|
2022-06-07 02:15:35 +00:00
|
|
|
|
|
|
|
# colorize grep output (good for log files)
|
|
|
|
alias \
|
|
|
|
grep="grep --color=auto" \
|
|
|
|
egrep="egrep --color=auto" \
|
|
|
|
fgrep="fgrep --color=auto"
|
|
|
|
|
|
|
|
# git
|
|
|
|
alias \
|
2023-06-20 14:29:23 +00:00
|
|
|
git-adu="git add -u" \
|
|
|
|
git-adl="git add ." \
|
|
|
|
git-brn="git branch" \
|
|
|
|
git-chk="git checkout" \
|
|
|
|
git-cln="git clone" \
|
|
|
|
git-cmt="git commit -m" \
|
|
|
|
git-fth="git fetch" \
|
|
|
|
git-pll="git pull origin" \
|
|
|
|
git-psh="git push origin" \
|
|
|
|
git-sts="git status" \
|
|
|
|
git-tag="git tag" \
|
|
|
|
git-ntg="git tag -a"
|
2022-06-07 02:15:35 +00:00
|
|
|
|
|
|
|
# adding flags
|
|
|
|
alias \
|
|
|
|
df="df -h" \
|
2022-10-27 16:23:56 +00:00
|
|
|
free="free -m"
|
|
|
|
|
2022-06-07 02:15:35 +00:00
|
|
|
# multimedia scripts
|
|
|
|
alias \
|
|
|
|
fli="flix-cli" \
|
|
|
|
ani="ani-cli" \
|
|
|
|
aniq="ani-cli -q"
|
|
|
|
|
|
|
|
# audio
|
|
|
|
alias \
|
|
|
|
mx="pulsemixer" \
|
|
|
|
amx="alsamixer" \
|
|
|
|
mk="cmus" \
|
|
|
|
ms="cmus" \
|
|
|
|
music="cmus"
|
|
|
|
|
|
|
|
# power management
|
2022-11-30 17:31:15 +00:00
|
|
|
alias \
|
|
|
|
po="systemctl poweroff" \
|
|
|
|
sp="systemctl suspend" \
|
|
|
|
rb="systemctl reboot"
|
2022-06-07 02:15:35 +00:00
|
|
|
|
|
|
|
# file management
|
|
|
|
alias \
|
2023-06-20 14:29:23 +00:00
|
|
|
fm="vifm" \
|
|
|
|
file="vifm" \
|
|
|
|
flm="vifm" \
|
2022-06-07 02:15:35 +00:00
|
|
|
rm="rm -vI" \
|
|
|
|
mv="mv -iv" \
|
|
|
|
cp="cp -iv" \
|
|
|
|
mkd="mkdir -pv"
|
|
|
|
|
|
|
|
# ps
|
|
|
|
alias \
|
|
|
|
psa="ps auxf" \
|
|
|
|
psgrep="ps aux | grep -v grep | grep -i -e VSZ -e" \
|
|
|
|
psmem="ps auxf | sort -nr -k 4" \
|
|
|
|
pscpu="ps auxf | sort -nr -k 3"
|
|
|
|
|
|
|
|
# youtube
|
|
|
|
alias \
|
|
|
|
yta-aac="yt-dlp --extract-audio --audio-format aac" \
|
|
|
|
yta-best="yt-dlp --extract-audio --audio-format best" \
|
|
|
|
yta-flac="yt-dlp --extract-audio --audio-format flac" \
|
|
|
|
yta-m4a="yt-dlp --extract-audio --audio-format m4a" \
|
|
|
|
yta-mp3="yt-dlp --extract-audio --audio-format mp3" \
|
|
|
|
yta-opus="yt-dlp --extract-audio --audio-format opus" \
|
|
|
|
yta-vorbis="yt-dlp --extract-audio --audio-format vorbis" \
|
|
|
|
yta-wav="yt-dlp --extract-audio --audio-format wav" \
|
|
|
|
ytv-best="yt-dlp -f bestvideo+bestaudio" \
|
2022-10-27 16:23:56 +00:00
|
|
|
yt="ytfzf -ftsl" \
|
|
|
|
ytm="ytfzf -mtsl"
|
2022-06-07 02:15:35 +00:00
|
|
|
|
|
|
|
# network and bluetooth
|
|
|
|
alias \
|
|
|
|
netstats="nmcli dev" \
|
|
|
|
wfi="nmtui-connect" \
|
2022-09-12 23:22:46 +00:00
|
|
|
wfi-scan="nmcli dev wifi rescan && nmcli dev wifi list" \
|
2022-06-07 02:15:35 +00:00
|
|
|
wfi-edit="nmtui-edit" \
|
|
|
|
wfi-on="nmcli radio wifi on" \
|
|
|
|
wfi-off="nmcli radio wifi off" \
|
|
|
|
blt="bluetoothctl"
|
|
|
|
|
|
|
|
### SETTING THE STARSHIP PROMPT ###
|
2023-01-20 18:15:37 +00:00
|
|
|
eval "$(starship init bash)"
|