Cleaning up shell configs.

This commit is contained in:
Derek Taylor
2024-04-16 20:12:20 -05:00
parent 67ddcb090f
commit 9862068abd
3 changed files with 118 additions and 115 deletions

127
.bashrc
View File

@@ -9,7 +9,6 @@
### EXPORT ### EXPORT
export TERM="xterm-256color" # getting proper colors export TERM="xterm-256color" # getting proper colors
export HISTCONTROL=ignoredups:erasedups # no duplicate entries export HISTCONTROL=ignoredups:erasedups # no duplicate entries
export ALTERNATE_EDITOR="" # setting for emacsclient
export EDITOR="emacsclient -t -a ''" # $EDITOR use Emacs in terminal export EDITOR="emacsclient -t -a ''" # $EDITOR use Emacs in terminal
export VISUAL="emacsclient -c -a emacs" # $VISUAL use Emacs in GUI mode export VISUAL="emacsclient -c -a emacs" # $VISUAL use Emacs in GUI mode
@@ -97,43 +96,65 @@ shopt -s checkwinsize # checks term size when bash regains control
bind "set completion-ignore-case on" bind "set completion-ignore-case on"
### COUNTDOWN ### COUNTDOWN
cdown () { cdown () {
N=$1 N=$1
while [[ $((--N)) > 0 ]] while [[ $((--N)) -gt 0 ]]
do do
echo "$N" | figlet -c | lolcat && sleep 1 echo "$N" | figlet -c | lolcat && sleep 1
done done
} }
### Function extract for common file formats ###
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
### ARCHIVE EXTRACTION ### ARCHIVE EXTRACTION
# usage: ex <file> # usage: ex <file>
ex () function ex {
{ if [ -z "$1" ]; then
if [ -f "$1" ] ; then # display usage if no parameters given
case $1 in echo "Usage: ex <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
*.tar.bz2) tar xjf $1 ;; echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
*.tar.gz) tar xzf $1 ;; else
*.bz2) bunzip2 $1 ;; for n in "$@"
*.rar) unrar x $1 ;; do
*.gz) gunzip $1 ;; if [ -f "$n" ] ; then
*.tar) tar xf $1 ;; case "${n%,}" in
*.tbz2) tar xjf $1 ;; *.cbt|*.tar.bz2|*.tar.gz|*.tar.xz|*.tbz2|*.tgz|*.txz|*.tar)
*.tgz) tar xzf $1 ;; tar xvf "$n" ;;
*.zip) unzip $1 ;; *.lzma) unlzma ./"$n" ;;
*.Z) uncompress $1;; *.bz2) bunzip2 ./"$n" ;;
*.7z) 7z x $1 ;; *.cbr|*.rar) unrar x -ad ./"$n" ;;
*.deb) ar x $1 ;; *.gz) gunzip ./"$n" ;;
*.tar.xz) tar xf $1 ;; *.cbz|*.epub|*.zip) unzip ./"$n" ;;
*.tar.zst) unzstd $1 ;; *.z) uncompress ./"$n" ;;
*) echo "'$1' cannot be extracted via ex()" ;; *.7z|*.arj|*.cab|*.cb7|*.chm|*.deb|*.dmg|*.iso|*.lzh|*.msi|*.pkg|*.rpm|*.udf|*.wim|*.xar)
esac 7z x ./"$n" ;;
else *.xz) unxz ./"$n" ;;
echo "'$1' is not a valid file" *.exe) cabextract ./"$n" ;;
fi *.cpio) cpio -id < ./"$n" ;;
*.cba|*.ace) unace x ./"$n" ;;
*)
echo "ex: '$n' - unknown archive method"
return 1
;;
esac
else
echo "'$n' - file does not exist"
return 1
fi
done
fi
}
IFS=$SAVEIFS
# Function for using Emacs as our manpage reader.
# Use :q to quit out of Emacs and return to the shell.
macsman() {
emacsclient -nw -e "(let ((Man-notify-method 'bully)) (man \"$1\") (define-key Man-mode-map \"q\" 'save-buffers-kill-emacs))"
} }
### ALIASES ###
# navigation # navigation
up () { up () {
local d="" local d=""
@@ -154,18 +175,29 @@ up () {
fi fi
} }
### ALIASES ###
# navigation
alias ..='cd ..'
alias ...='cd ../..'
alias .3='cd ../../..'
alias .4='cd ../../../..'
alias .5='cd ../../../../..'
# vim and emacs # vim and emacs
alias vim="nvim" alias vim="nvim"
alias em="/usr/bin/emacs -nw" alias emacs="emacsclient -c -a 'emacs'" # GUI versions of Emacs
alias emacs="emacsclient -c -a 'emacs'" alias em="/usr/bin/emacs -nw" # Terminal version of Emacs
alias rem="killall emacs || echo 'Emacs server not running'; /usr/bin/emacs --daemon" alias rem="killall emacs || echo 'Emacs server not running'; /usr/bin/emacs --daemon" # Kill Emacs and restart daemon..
alias man="macsman" # Use emacs as your manpage reader.
# Changing "ls" to "eza" # Changing "ls" to "eza"
alias ls='eza -al --color=always --group-directories-first' # my preferred listing alias ls='eza -al --color=always --group-directories-first' # my preferred listing
alias la='eza -a --color=always --group-directories-first' # all files and dirs alias la='eza -a --color=always --group-directories-first' # all files and dirs
alias ll='eza -l --color=always --group-directories-first' # long format alias ll='eza -l --color=always --group-directories-first' # long format
alias lt='eza -aT --color=always --group-directories-first' # tree listing alias lt='eza -aT --color=always --group-directories-first' # tree listing
alias l.='eza -a | egrep "^\."' alias l.='eza -al --color=always --group-directories-first ../' # ls on the PARENT directory
alias l..='eza -al --color=always --group-directories-first ../../' # ls on directory 2 levels up
alias l...='eza -al --color=always --group-directories-first ../../../' # ls on directory 3 levels up
# pacman and yay # pacman and yay
alias pacsyu='sudo pacman -Syu' # update only standard pkgs alias pacsyu='sudo pacman -Syu' # update only standard pkgs
@@ -173,7 +205,7 @@ alias pacsyyu='sudo pacman -Syyu' # Refresh pkglist & update stan
alias parsua='paru -Sua --noconfirm' # update only AUR pkgs (paru) alias parsua='paru -Sua --noconfirm' # update only AUR pkgs (paru)
alias parsyu='paru -Syu --noconfirm' # update standard pkgs and AUR pkgs (paru) alias parsyu='paru -Syu --noconfirm' # update standard pkgs and AUR pkgs (paru)
alias unlock='sudo rm /var/lib/pacman/db.lck' # remove pacman lock alias unlock='sudo rm /var/lib/pacman/db.lck' # remove pacman lock
alias cleanup='sudo pacman -Rns $(pacman -Qtdq)' # remove orphaned packages (DANGEROUS!) alias orphan='sudo pacman -Rns $(pacman -Qtdq)' # remove orphaned packages (DANGEROUS!)
# get fastest mirrors # get fastest mirrors
alias mirror="sudo reflector -f 30 -l 30 --number 10 --verbose --save /etc/pacman.d/mirrorlist" alias mirror="sudo reflector -f 30 -l 30 --number 10 --verbose --save /etc/pacman.d/mirrorlist"
@@ -181,14 +213,10 @@ alias mirrord="sudo reflector --latest 50 --number 20 --sort delay --save /etc/p
alias mirrors="sudo reflector --latest 50 --number 20 --sort score --save /etc/pacman.d/mirrorlist" alias mirrors="sudo reflector --latest 50 --number 20 --sort score --save /etc/pacman.d/mirrorlist"
alias mirrora="sudo reflector --latest 50 --number 20 --sort age --save /etc/pacman.d/mirrorlist" alias mirrora="sudo reflector --latest 50 --number 20 --sort age --save /etc/pacman.d/mirrorlist"
# Colorize grep output (good for log files)
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
# adding flags # adding flags
alias df='df -h' # human-readable sizes alias df='df -h' # human-readable sizes
alias free='free -m' # show sizes in MB alias free='free -m' # show sizes in MB
alias grep='grep --color=auto' # colorize output (good for log files)
# ps # ps
alias psa="ps auxf" alias psa="ps auxf"
@@ -222,22 +250,12 @@ alias gpg-check="gpg2 --keyserver-options auto-key-retrieve --verify"
# receive the key of a developer # receive the key of a developer
alias gpg-retrieve="gpg2 --keyserver-options auto-key-retrieve --receive-keys" alias gpg-retrieve="gpg2 --keyserver-options auto-key-retrieve --receive-keys"
# Play audio files in current dir by type # change your default USER shell
alias playwav='vlc *.wav' alias tobash="sudo chsh $USER -s /bin/bash && echo 'Log out and log back in for change to take effect.'"
alias playogg='vlc *.ogg' alias tozsh="sudo chsh $USER -s /bin/zsh && echo 'Log out and log back in for change to take effect.'"
alias playmp3='vlc *.mp3' alias tofish="sudo chsh $USER -s /bin/fish && echo 'Log out and log back in for change to take effect.'"
# Play video files in current dir by type # bare git repo alias for managing my dotfiles
alias playavi='vlc *.avi'
alias playmov='vlc *.mov'
alias playmp4='vlc *.mp4'
# switch between shells
alias tobash="sudo chsh $USER -s /bin/bash && echo 'Now log out.'"
alias tozsh="sudo chsh $USER -s /bin/zsh && echo 'Now log out.'"
alias tofish="sudo chsh $USER -s /bin/fish && echo 'Now log out.'"
# bare git repo alias for dotfiles
alias config="/usr/bin/git --git-dir=$HOME/dotfiles --work-tree=$HOME" alias config="/usr/bin/git --git-dir=$HOME/dotfiles --work-tree=$HOME"
# termbin # termbin
@@ -253,4 +271,3 @@ colorscript random
### SETTING THE STARSHIP PROMPT ### ### SETTING THE STARSHIP PROMPT ###
eval "$(starship init bash)" eval "$(starship init bash)"
[ -f /opt/miniconda3/etc/profile.d/conda.sh ] && source /opt/miniconda3/etc/profile.d/conda.sh

View File

@@ -149,9 +149,10 @@ alias .5='cd ../../../../..'
# vim and emacs # vim and emacs
alias vim='nvim' alias vim='nvim'
alias em='/usr/bin/emacs -nw'
alias emacs="emacsclient -c -a 'emacs'" alias emacs="emacsclient -c -a 'emacs'"
alias rem="killall emacs || echo 'Emacs server not running'; /usr/bin/emacs --daemon" alias em='/usr/bin/emacs -nw'
alias rem="killall emacs || echo 'Emacs server not running'; /usr/bin/emacs --daemon" # Kill Emacs and restart daemon..
alias man="macsman" # Use emacs as your manpage reader.
# Changing "ls" to "eza" # Changing "ls" to "eza"
alias ls='eza -al --color=always --group-directories-first' # my preferred listing alias ls='eza -al --color=always --group-directories-first' # my preferred listing
@@ -159,6 +160,9 @@ alias la='eza -a --color=always --group-directories-first' # all files and dirs
alias ll='eza -l --color=always --group-directories-first' # long format alias ll='eza -l --color=always --group-directories-first' # long format
alias lt='eza -aT --color=always --group-directories-first' # tree listing alias lt='eza -aT --color=always --group-directories-first' # tree listing
alias l.='eza -a | egrep "^\."' alias l.='eza -a | egrep "^\."'
alias l.='eza -al --color=always --group-directories-first ../' # ls on the PARENT directory
alias l..='eza -al --color=always --group-directories-first ../../' # ls on directory 2 levels up
alias l...='eza -al --color=always --group-directories-first ../../../' # ls on directory 3 levels up
# pacman and yay # pacman and yay
alias pacsyu='sudo pacman -Syu' # update only standard pkgs alias pacsyu='sudo pacman -Syu' # update only standard pkgs
@@ -166,7 +170,7 @@ alias pacsyyu='sudo pacman -Syyu' # Refresh pkglist & update stan
alias parsua='paru -Sua --noconfirm' # update only AUR pkgs (paru) alias parsua='paru -Sua --noconfirm' # update only AUR pkgs (paru)
alias parsyu='paru -Syu --noconfirm' # update standard pkgs and AUR pkgs (paru) alias parsyu='paru -Syu --noconfirm' # update standard pkgs and AUR pkgs (paru)
alias unlock='sudo rm /var/lib/pacman/db.lck' # remove pacman lock alias unlock='sudo rm /var/lib/pacman/db.lck' # remove pacman lock
alias cleanup='sudo pacman -Rns (pacman -Qtdq)' # remove orphaned packages (DANGEROUS!) alias orphan='sudo pacman -Rns (pacman -Qtdq)' # remove orphaned packages (DANGEROUS!)
# get fastest mirrors # get fastest mirrors
alias mirror="sudo reflector -f 30 -l 30 --number 10 --verbose --save /etc/pacman.d/mirrorlist" alias mirror="sudo reflector -f 30 -l 30 --number 10 --verbose --save /etc/pacman.d/mirrorlist"
@@ -174,14 +178,10 @@ alias mirrord="sudo reflector --latest 50 --number 20 --sort delay --save /etc/p
alias mirrors="sudo reflector --latest 50 --number 20 --sort score --save /etc/pacman.d/mirrorlist" alias mirrors="sudo reflector --latest 50 --number 20 --sort score --save /etc/pacman.d/mirrorlist"
alias mirrora="sudo reflector --latest 50 --number 20 --sort age --save /etc/pacman.d/mirrorlist" alias mirrora="sudo reflector --latest 50 --number 20 --sort age --save /etc/pacman.d/mirrorlist"
# Colorize grep output (good for log files)
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
# adding flags # adding flags
alias df='df -h' # human-readable sizes alias df='df -h' # human-readable sizes
alias free='free -m' # show sizes in MB alias free='free -m' # show sizes in MB
alias grep='grep --color=auto' # colorize output (good for log files)
# ps # ps
alias psa="ps auxf" alias psa="ps auxf"
@@ -214,16 +214,6 @@ alias gpg-check="gpg2 --keyserver-options auto-key-retrieve --verify"
# receive the key of a developer # receive the key of a developer
alias gpg-retrieve="gpg2 --keyserver-options auto-key-retrieve --receive-keys" alias gpg-retrieve="gpg2 --keyserver-options auto-key-retrieve --receive-keys"
# Play audio files in current dir by type
alias playwav='vlc *.wav'
alias playogg='vlc *.ogg'
alias playmp3='vlc *.mp3'
# Play video files in current dir by type
alias playavi='vlc *.avi'
alias playmov='vlc *.mov'
alias playmp4='vlc *.mp4'
# switch between shells # switch between shells
alias tobash="sudo chsh $USER -s /bin/bash && echo 'Now log out.'" alias tobash="sudo chsh $USER -s /bin/bash && echo 'Now log out.'"
alias tozsh="sudo chsh $USER -s /bin/zsh && echo 'Now log out.'" alias tozsh="sudo chsh $USER -s /bin/zsh && echo 'Now log out.'"

76
.zshrc
View File

@@ -76,14 +76,25 @@ case ${TERM} in
;; ;;
esac esac
### COUNTDOWN
cdown () {
N=$1
while [[ $((--N)) -gt 0 ]]
do
echo "$N" | figlet -c | lolcat && sleep 1
done
}
### Function extract for common file formats ### ### Function extract for common file formats ###
SAVEIFS=$IFS SAVEIFS=$IFS
IFS=$(echo -en "\n\b") IFS=$(echo -en "\n\b")
function extract { ### ARCHIVE EXTRACTION
# usage: ex <file>
function ex {
if [ -z "$1" ]; then if [ -z "$1" ]; then
# display usage if no parameters given # 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 "Usage: ex <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]" echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
else else
for n in "$@" for n in "$@"
@@ -105,7 +116,7 @@ function extract {
*.cpio) cpio -id < ./"$n" ;; *.cpio) cpio -id < ./"$n" ;;
*.cba|*.ace) unace x ./"$n" ;; *.cba|*.ace) unace x ./"$n" ;;
*) *)
echo "extract: '$n' - unknown archive method" echo "ex: '$n' - unknown archive method"
return 1 return 1
;; ;;
esac esac
@@ -119,10 +130,11 @@ fi
IFS=$SAVEIFS IFS=$SAVEIFS
### ALIASES ### # Function for using Emacs as our manpage reader.
# Use :q to quit out of Emacs and return to the shell.
# root privileges macsman() {
alias doas="doas --" emacsclient -nw -e "(let ((Man-notify-method 'bully)) (man \"$1\") (define-key Man-mode-map \"q\" 'save-buffers-kill-emacs))"
}
# navigation # navigation
up () { up () {
@@ -144,18 +156,22 @@ up () {
fi fi
} }
### ALIASES ###
# vim and emacs # vim and emacs
alias vim="nvim" alias vim="nvim"
alias em="/usr/bin/emacs -nw" alias emacs="emacsclient -c -a 'emacs'" # GUI versions of Emacs
alias emacs="emacsclient -c -a 'emacs'" alias em="/usr/bin/emacs -nw" # Terminal version of Emacs
alias rem="killall emacs || echo 'Emacs server not running'; /usr/bin/emacs --daemon" alias rem="killall emacs || echo 'Emacs server not running'; /usr/bin/emacs --daemon" # Kill Emacs and restart daemon..
alias man="macsman" # Use emacs as your manpage reader.
# Changing "ls" to "eza" # Changing "ls" to "eza"
alias ls='eza -al --color=always --group-directories-first' # my preferred listing alias ls='eza -al --color=always --group-directories-first' # my preferred listing
alias la='eza -a --color=always --group-directories-first' # all files and dirs alias la='eza -a --color=always --group-directories-first' # all files and dirs
alias ll='eza -l --color=always --group-directories-first' # long format alias ll='eza -l --color=always --group-directories-first' # long format
alias lt='eza -aT --color=always --group-directories-first' # tree listing alias lt='eza -aT --color=always --group-directories-first' # tree listing
alias l.='eza -a | egrep "^\."' alias l.='eza -al --color=always --group-directories-first ../' # ls on the PARENT directory
alias l..='eza -al --color=always --group-directories-first ../../' # ls on directory 2 levels up
alias l...='eza -al --color=always --group-directories-first ../../../' # ls on directory 3 levels up
# pacman and yay # pacman and yay
alias pacsyu='sudo pacman -Syu' # update only standard pkgs alias pacsyu='sudo pacman -Syu' # update only standard pkgs
@@ -163,7 +179,7 @@ alias pacsyyu='sudo pacman -Syyu' # Refresh pkglist & update stan
alias parsua='paru -Sua --noconfirm' # update only AUR pkgs (paru) alias parsua='paru -Sua --noconfirm' # update only AUR pkgs (paru)
alias parsyu='paru -Syu --noconfirm' # update standard pkgs and AUR pkgs (paru) alias parsyu='paru -Syu --noconfirm' # update standard pkgs and AUR pkgs (paru)
alias unlock='sudo rm /var/lib/pacman/db.lck' # remove pacman lock alias unlock='sudo rm /var/lib/pacman/db.lck' # remove pacman lock
alias cleanup='sudo pacman -Rns $(pacman -Qtdq)' # remove orphaned packages (DANGEROUS!) alias orphan='sudo pacman -Rns $(pacman -Qtdq)' # remove orphaned packages (DANGEROUS!)
# get fastest mirrors # get fastest mirrors
alias mirror="sudo reflector -f 30 -l 30 --number 10 --verbose --save /etc/pacman.d/mirrorlist" alias mirror="sudo reflector -f 30 -l 30 --number 10 --verbose --save /etc/pacman.d/mirrorlist"
@@ -171,14 +187,10 @@ alias mirrord="sudo reflector --latest 50 --number 20 --sort delay --save /etc/p
alias mirrors="sudo reflector --latest 50 --number 20 --sort score --save /etc/pacman.d/mirrorlist" alias mirrors="sudo reflector --latest 50 --number 20 --sort score --save /etc/pacman.d/mirrorlist"
alias mirrora="sudo reflector --latest 50 --number 20 --sort age --save /etc/pacman.d/mirrorlist" alias mirrora="sudo reflector --latest 50 --number 20 --sort age --save /etc/pacman.d/mirrorlist"
# Colorize grep output (good for log files)
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
# adding flags # adding flags
alias df='df -h' # human-readable sizes alias df='df -h' # human-readable sizes
alias free='free -m' # show sizes in MB alias free='free -m' # show sizes in MB
alias grep='grep --color=auto' # colorize output (good for log files)
# ps # ps
alias psa="ps auxf" alias psa="ps auxf"
@@ -212,22 +224,12 @@ alias gpg-check="gpg2 --keyserver-options auto-key-retrieve --verify"
# receive the key of a developer # receive the key of a developer
alias gpg-retrieve="gpg2 --keyserver-options auto-key-retrieve --receive-keys" alias gpg-retrieve="gpg2 --keyserver-options auto-key-retrieve --receive-keys"
# Play audio files in current dir by type # change your default USER shell
alias playwav='vlc *.wav' alias tobash="sudo chsh $USER -s /bin/bash && echo 'Log out and log back in for change to take effect.'"
alias playogg='vlc *.ogg' alias tozsh="sudo chsh $USER -s /bin/zsh && echo 'Log out and log back in for change to take effect.'"
alias playmp3='vlc *.mp3' alias tofish="sudo chsh $USER -s /bin/fish && echo 'Log out and log back in for change to take effect.'"
# Play video files in current dir by type # bare git repo alias for managing my dotfiles
alias playavi='vlc *.avi'
alias playmov='vlc *.mov'
alias playmp4='vlc *.mp4'
# switch between shells
alias tobash="sudo chsh $USER -s /bin/bash && echo 'Now log out.'"
alias tozsh="sudo chsh $USER -s /bin/zsh && echo 'Now log out.'"
alias tofish="sudo chsh $USER -s /bin/fish && echo 'Now log out.'"
# bare git repo alias for dotfiles
alias config="/usr/bin/git --git-dir=$HOME/dotfiles --work-tree=$HOME" alias config="/usr/bin/git --git-dir=$HOME/dotfiles --work-tree=$HOME"
# termbin # termbin
@@ -241,11 +243,5 @@ alias rr='curl -s -L https://raw.githubusercontent.com/keroserene/rickrollrc/mas
# Or install it from the Arch User Repository: shell-color-scripts # Or install it from the Arch User Repository: shell-color-scripts
colorscript random colorscript random
### BASH INSULTER (works in zsh though) ###
if [ -f /etc/bash.command-not-found ]; then
. /etc/bash.command-not-found
fi
### SETTING THE STARSHIP PROMPT ### ### SETTING THE STARSHIP PROMPT ###
eval "$(starship init zsh)" eval "$(starship init zsh)"