232 lines
6.8 KiB
Bash
232 lines
6.8 KiB
Bash
## ____ __
|
|
## / __ \_________ _/ /_____
|
|
## / / / / ___/ __ `/ //_/ _ \
|
|
## / /_/ / / / /_/ / ,< / __/ Clay Gomera (Drake)
|
|
## /_____/_/ \__,_/_/|_|\___/ My custom zsh config
|
|
##
|
|
|
|
### EXPORT
|
|
export TERM="xterm-256color" # getting proper colors
|
|
export HISTORY_IGNORE="(ls|cd|pwd|exit|sudo reboot|history|cd -|cd ..)"
|
|
export EDITOR="nvim" # $EDITOR use neovim
|
|
export READER="zathura"
|
|
export TERMINAL="alacritty"
|
|
export BROWSER="qutebrowser"
|
|
export WM="dwm"
|
|
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
|
|
export XDG_DATA_HOME=${XDG_DATA_HOME:="$HOME/.local/share"}
|
|
export XDG_CACHE_HOME=${XDG_CACHE_HOME:="$HOME/.cache"}
|
|
export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:="$HOME/.config"}
|
|
|
|
### SET MANPAGER
|
|
### "bat" as manpager
|
|
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
|
|
|
|
### SET VI MODE ###
|
|
# Comment this line out to enable default emacs-like bindings
|
|
bindkey -v
|
|
|
|
# If not running interactively, don't do anything
|
|
[[ $- != *i* ]] && return
|
|
|
|
### 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
|
|
|
|
### Function extract for common file formats ###
|
|
SAVEIFS=$IFS
|
|
IFS=$(echo -en "\n\b")
|
|
|
|
function extract {
|
|
if [ -z "$1" ]; then
|
|
# display usage if no parameters given
|
|
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
|
|
echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
|
|
else
|
|
for n in "$@"
|
|
do
|
|
if [ -f "$n" ] ; then
|
|
case "${n%,}" in
|
|
*.cbt|*.tar.bz2|*.tar.gz|*.tar.xz|*.tbz2|*.tgz|*.txz|*.tar)
|
|
tar xvf "$n" ;;
|
|
*.lzma) unlzma ./"$n" ;;
|
|
*.bz2) bunzip2 ./"$n" ;;
|
|
*.cbr|*.rar) unrar x -ad ./"$n" ;;
|
|
*.gz) gunzip ./"$n" ;;
|
|
*.cbz|*.epub|*.zip) unzip ./"$n" ;;
|
|
*.z) uncompress ./"$n" ;;
|
|
*.7z|*.arj|*.cab|*.cb7|*.chm|*.deb|*.dmg|*.iso|*.lzh|*.msi|*.pkg|*.rpm|*.udf|*.wim|*.xar)
|
|
7z x ./"$n" ;;
|
|
*.xz) unxz ./"$n" ;;
|
|
*.exe) cabextract ./"$n" ;;
|
|
*.cpio) cpio -id < ./"$n" ;;
|
|
*.cba|*.ace) unace x ./"$n" ;;
|
|
*)
|
|
echo "extract: '$n' - unknown archive method"
|
|
return 1
|
|
;;
|
|
esac
|
|
else
|
|
echo "'$n' - file does not exist"
|
|
return 1
|
|
fi
|
|
done
|
|
fi
|
|
}
|
|
|
|
IFS=$SAVEIFS
|
|
|
|
### 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
|
|
}
|
|
alias ..='cd ..'
|
|
alias .2='cd ../..'
|
|
alias .3='cd ../../..'
|
|
alias .4='cd ../../../..'
|
|
alias .5='cd ../../../../..'
|
|
|
|
# bat as cat
|
|
alias cat='bat'
|
|
|
|
# editors
|
|
alias vim='nvim'
|
|
|
|
# Changing "ls" to "exa"
|
|
alias ls='exa -al --color=always --group-directories-first' # my preferred listing
|
|
alias la='exa -a --color=always --group-directories-first' # all files and dirs
|
|
alias ll='exa -l --color=always --group-directories-first' # long format
|
|
alias lt='exa -aT --color=always --group-directories-first' # tree listing
|
|
alias l.='exa -a | egrep "^\."'
|
|
|
|
# xbps
|
|
alias xb-up='sudo xbps-install -Su && xcheckrestart' # Refresh pkglist & update standard pkgs
|
|
alias xb-get='sudo xbps-install -S' # Install a package
|
|
alias xb-rmv='sudo xbps-remove -R' # Remove a package with all its dependencies
|
|
alias xb-rmv-sec='sudo xbps-remove' # Remove a package with all its dependencies (secure way)
|
|
alias xb-qry='sudo xbps-query' # Repo query
|
|
alias xb-cln='sudo xbps-remove -o && sudo xbps-remove -O' # remove orphaned packages
|
|
|
|
# Colorize grep output (good for log files)
|
|
alias grep='grep --color=auto'
|
|
alias egrep='egrep --color=auto'
|
|
alias fgrep='fgrep --color=auto'
|
|
|
|
# confirm before overwriting something
|
|
alias rm='rm -i'
|
|
alias mv='mv -i'
|
|
alias cp='cp -i'
|
|
|
|
# git
|
|
alias addup='git add -u'
|
|
alias addall='git add .'
|
|
alias branch='git branch'
|
|
alias checkout='git checkout'
|
|
alias clone='git clone'
|
|
alias commit='git commit -m'
|
|
alias fetch='git fetch'
|
|
alias pull='git pull origin'
|
|
alias push='git push origin'
|
|
alias stat='git status' # 'status' is protected name so using 'stat' instead
|
|
alias tag='git tag'
|
|
alias newtag='git tag -a'
|
|
|
|
# adding flags
|
|
alias df='df -h' # human-readable sizes
|
|
alias free='free -m' # show sizes in MB
|
|
alias newsboat='newsboat -u ~/.config/newsboat/urls' # start newsboat with my urls file
|
|
|
|
# ani-cli
|
|
alias ani='ani-cli'
|
|
alias ani-q='ani-cli -q' # to select video quality
|
|
|
|
# ytfzf
|
|
alias yt='ytfzf -f -t'
|
|
|
|
# flix-cli
|
|
alias fli='flix-cli'
|
|
|
|
# mount and unmount drives
|
|
alias mnt='sudo mount'
|
|
alias umnt='sudo umount'
|
|
|
|
# mixers
|
|
alias mx='pulsemixer'
|
|
alias amx='alsamixer'
|
|
|
|
# music player
|
|
alias mk='cmus'
|
|
|
|
# power management
|
|
alias po='loginctl poweroff'
|
|
alias sp='loginctl suspend'
|
|
alias rb='loginctl reboot'
|
|
|
|
# file manager
|
|
alias fm='./.config/vifm/scripts/vifmrun'
|
|
alias vifm='./.config/vifm/scripts/vifmrun'
|
|
|
|
# ps
|
|
alias psa="ps auxf"
|
|
alias psgrep="ps aux | grep -v grep | grep -i -e VSZ -e"
|
|
alias psmem='ps auxf | sort -nr -k 4'
|
|
alias pscpu='ps auxf | sort -nr -k 3'
|
|
|
|
# youtube-dl
|
|
alias yta-aac="yt-dlp --extract-audio --audio-format aac "
|
|
alias yta-best="yt-dlp --extract-audio --audio-format best "
|
|
alias yta-flac="yt-dlp --extract-audio --audio-format flac "
|
|
alias yta-m4a="yt-dlp --extract-audio --audio-format m4a "
|
|
alias yta-mp3="yt-dlp --extract-audio --audio-format mp3 "
|
|
alias yta-opus="yt-dlp --extract-audio --audio-format opus "
|
|
alias yta-vorbis="yt-dlp --extract-audio --audio-format vorbis "
|
|
alias yta-wav="yt-dlp --extract-audio --audio-format wav "
|
|
alias ytv-best="yt-dlp -f bestvideo+bestaudio "
|
|
|
|
# Network Manager and bluetooth
|
|
alias netstats='nmcli dev'
|
|
alias wfi='nmtui-connect'
|
|
alias wfi-scan='nmcli dev wifi list'
|
|
alias wfi-edit='nmtui-edit'
|
|
alias wfi-on='nmcli radio wifi on'
|
|
alias wfi-off='nmcli radio wifi off'
|
|
alias blt='bluetoothctl'
|
|
|
|
### SETTING THE STARSHIP PROMPT ###
|
|
eval "$(starship init bash)"
|