more aliases for arch

main
Matt Clark 2022-02-25 04:26:13 +00:00 committed by CrimsonTome
parent 4c8cca442b
commit 6be9602ed0
1 changed files with 116 additions and 50 deletions

View File

@ -8,8 +8,7 @@
alias ls='ls -Al --color=auto'
#sets the prompt to the userame@hostname with the full working directory, starts a newline for the command to be on
PS1="\u@\h~$
\w"$(tput setaf 2)" "$(tput blink)" > "$(tput sgr0)" "
PS1=$"\w\n💻"$(tput blink)"-> "$(tput sgr0)
########
#ALCI
@ -17,39 +16,54 @@ PS1="\u@\h~$
alias evb='sudo systemctl enable --now vboxservice.service'
#######
#user aliases
#some adapted from sbrl's bash aliases
alias pi='sudo pacman -S'
alias pu='sudo pacman -Syu'
alias gc='git clone'
alias gpl='git pull'
alias gph='git push'
alias gl='git log'
alias gac='git commit -am'
alias gs='git status'
alias untar='tar -zxvf'
alias ipe='curl ipinfo.io/ip'
alias c='clear'
alias words='wc -w'
alias yt='youtube-dl'
alias mp3='youtube-dl -x --audio-format mp3'
alias eb='clear && exec bash'
alias back='cd -'
alias mkdir='mkdir -pv'
alias rm='rm -vi'
alias rmr='rm -rv'
alias rmdir='rmdir -vi'
alias cp='cp -vi'
alias mv='mv -vi'
alias upstats='echo "Up since:" && uptime -s && uptime -p'
alias sshserver='ssh root@192.168.100.2'
alias restartwifi='sudo systemctl restart iwd.service'
#comments should probably be added here
alias pi='sudo pacman -S' #installs a package
alias pu='sudo pacman -Syu' #updates the system
alias pr='sudo pacman -Rns' #removes a package and all it's dependencies that aren't needed by other packages
alias ps='pacman -Ss' #package search
alias psi='pacman -Qi' #info about an installed package
alias psd='pacman -Sii' #info about list-installed package and its dependencies
alias pls='pacman -Qeq' #list pacman packages explicitly installed
alias aurls='pacman -Qmq' #list aur packages
alias yu='yay -Sua' #updates aur packages
alias yi='yay -S' #installs an aur package
alias yr='yay -Rns' #removes an aur package
alias pcc='sudo pacman -Sc' #clear package cache except installed packages (only do if in need of space)
alias pccc='pacman -Scc' #clear ALL of the package cache (ONLY DO IF IN NEED OF SERIOUS SPACE)
alias gc='git clone' #clone a git repo
alias gpl='git pull' #pull updates from a git repo
alias gph='git push' #push local updates to a git repo
alias gl='git log' #check git log
alias gac='git commit -am' #adds all changes to commit and add a comment
alias gs='git status' #check git status
alias untar='tar -zxvf' #extract files from archive
alias ipe='curl ipinfo.io/ip' #check external ip address
alias c='clear' #clear terminal
alias words='wc -w' #check word count of a file
alias yt='yt-dlp' #download a YT video
alias mp3='yt-dlp -x --audio-format mp3' #grab the mp3 of a YT video
alias eb='clear && exec bash' #reload bash and clear the terminal screen
alias back='cd -' #go back to the directory you were in previously (should probably add some pushd stuff here)
# -v adds verbosity, -i makes it interactive
alias mkdir='mkdir -pv' #make a directory allowing for layering e.g. mkdir foo/bar/
alias rm='rm -vi' #remove file
alias rmr='rm -rv' #remove recursively
alias rmdir='rmdir -v' #remove directory
alias cp='cp -vi' #copy
alias cpdir='cp -vr' #copy directory and contents
alias mv='mv -vi' #move
alias upstats='echo "Up since:" && uptime -s && uptime -p' #displays uptime stats
alias sshserver='mosh root@192.168.100.2' #ssh's into my server
alias restartwifi='sudo systemctl restart iwd.service' #restarts the WiFi service, it can be a bit weird on Arch, this sometimes helps
alias sudo='sudo -p "$(printf "\033[1;31mPassword: \033[0;0m" )"'
#end of manual aliases
#user functions
up () {
up () { #goes up x directories
local d=""
local limit="$1"
@ -68,56 +82,108 @@ up () {
fi
}
#### from https://github.com/dylanaraps/pure-bash-bible/blob/master/README.md
# from https://github.com/dylanaraps/pure-bash-bible/blob/master/README.md
bkr() {
bkr() { #runs a command in the background
(nohup "$@" &>/dev/null &)
}
bkr ./some_script.sh # some_script.sh is now running in the background
trim_all() {
trim_all() { #trim all y from string x
# Usage: trim_all " example string "
set -f
set -- $*
printf '%s\n' "$*"
printf '%s
' "$*"
set +f
}
split() {
split() { #split a string based on a delimiter
# Usage: split "string" "delimiter"
IFS=$'\n' read -d "" -ra arr <<< "${1//$2/$'\n'}"
printf '%s\n' "${arr[@]}"
IFS=$'
' read -d "" -ra arr <<< "${1//$2/$'
'}"
printf '%s
' "${arr[@]}"
}
lower() {
lower() { #convert to lowercase
# Usage: lower "string"
printf '%s\n' "${1,,}"
printf '%s
' "${1,,}"
}
upper() {
upper() { #convert to uppercase
# Usage: upper "string"
printf '%s\n' "${1^^}"
printf '%s
' "${1^^}"
}
reverse_case() {
reverse_case() { #reverse the case of a string
# Usage: reverse_case "string"
printf '%s\n' "${1~~}"
printf '%s
' "${1~~}"
}
strip_all() {
strip_all() { #strp all y from x
# Usage: strip_all "string" "pattern"
printf '%s\n' "${1//$2}"
printf '%s
' "${1//$2}"
}
lines() {
lines() { #show line count of file
# Usage: lines "file"
mapfile -tn 0 lines < "$1"
printf '%s\n' "${#lines[@]}"
printf '%s
' "${#lines[@]}"
}
lspkg() { #list packages in interactive format
pacman -Qeq | fzf --preview 'pacman -Qil {}' --layout=reverse --bind 'enter:execute(pacman -Qil {} | less)'
}
rmo() { #remove orphans
sudo pacman -Qtdq |sudo pacman -Rns -
}
# end of user functions
#startup commands
PF_INFO="ascii title os host kernel uptime pkgs memory shell editor wm de" pfetch|lolcat
PF_INFO="ascii title os host kernel uptime shell wm de" pfetch|lolcat #displays sysem info on bash startup
# kdesrc-build #################################################################
## Add kdesrc-build to PATH
export PATH="$HOME/kde/src/kdesrc-build:$PATH"
## Autocomplete for kdesrc-run
function _comp_kdesrc_run
{
local cur
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
# Complete only the first argument
if [[ $COMP_CWORD != 1 ]]; then
return 0
fi
# Retrieve build modules through kdesrc-run
# If the exit status indicates failure, set the wordlist empty to avoid
# unrelated messages.
local modules
if ! modules=$(kdesrc-run --list-installed);
then
modules=""
fi
# Return completions that match the current word
COMPREPLY=( $(compgen -W "${modules}" -- "$cur") )
return 0
}
## Register autocomplete function
complete -o nospace -F _comp_kdesrc_run kdesrc-run
################################################################################