1

Topic: My .bash_aliases file :3

Do whatever you want with this <3

#DEVUAN-DEBIAN TO HYPERBOLA BASH ALIASES
 
#I originally made these aliases for Debian and/or Devuan GNU+Linux,
#but since I've switched to Hyperbola I have decided to modify them.
#You may want to use them if you are new to Hyperbola and/or
#Pacman-based distros. With the exception of Alpine, all the UNIX-like
#systems I have used prior to Hyperbola GNU+Linux were based on Debian,
#but I am quickly learning the hyper way. Do take what I say about
#pacman with a grain of salt, though. You may want to read pacman's
#info/man pages as pacman has some interesting functionality which is
#not documented here.
 
#WAIVER: To make this file as libre as possible, any restrictive powers 
#assigned to me over it are relinquished, to the fullest extent allowed, 
#under CC0 (https://directory.fsf.org/wiki/License:CC0) + Miloslav Číž's 
#ip_waiver
#(https://codeberg.org/drummyfish/my_text_data/raw/branch/master/ip_waiver.txt)

#SUPERUSER ALIASES:
alias su="su --login"                
#This command lets me log into the root account. Login variable allows
#root's .bashrc file to be read; I have modified root's .bashrc file so
#that it redirects to my user's alias file (this one), therefore the
#--login variable allows me to run the aliases from this file as root.
#The --preserve-environment variable can achieve the same effect
#without meddling with root's .bashrc file, but I do not recommend it
#as it has caused me negative side-effects when it comes to bash
#history.

alias sudo="doas"
#From the period where I was trying to transition from sudo to doas.

alias S="doas"
#The S is for sudo, referencing the alias above. Note: When two
#1-letter aliases use the same letter, the authoritarian commands such
#as doas use uppercase aliases, while less menacing commands are in
#lowercase. This allows me to create more 1-letter aliases. 

alias d="doas"
#Self-explanatory.

#NON-ROOT PACMAN ALIASES:
alias sh="pacman -Sii"
#This alias was originally for "apt show" (the "sh" is for "show").
#This command has been converted to a pacman alternative which serves
#the same purpose (showing information about a package). This alias
#overrides the "sh" command, therefore it might cause some code to
#break. 

alias s="pacman -Ss"
#The "s" is for "apt search", also converted to a similar pacman
#alternative.

#ROOT PACMAN ALIASES:
#alias b="doas pacman build-dep"
#Unlike the previous package manager commands, I haven't properly
#converted this command to Hyperbola, therefore it has been disabled
#with a hashtag.

alias u="doas pacman -Syy"
#For "doas apt update". The double "y" is optional, therefore you
#could use "doas pacman -Sy" instead, but the double "y" guarantees
#that pacman will try to fetch a more up-to-date package index even if
#it believes that the current index in your system is already
#up-to-date 

alias i="doas pacman -S"
#For "doas apt install". Can also be used to reinstall packages.

alias a="doas pacman -Qdt"
#For doas apt autoremove. Unlike in Debian, this will not
#automatically delete orphan packages, just list them. I have found no
#pacman equivalent that automatically removes orphans.

alias U="doas pacman -Su"
#For "doas apt upgrade". This will try to upgrade your system's
#packages based on the package index stored on your system, therefore
#you MUST run the lowercase "u" alias beforehand. This is to comply
#with my tradition of running "sudo apt update" and "sudo apt upgrade"
#separately. You may change this alias to "doas pacman -Syyu"; then you
#will no longer have to use the lowercase "u" alias because pacman will
#automatically fetch a new package index before upgrading your
#packages. 

#alias g="doas pacman-get source"
#For doas apt-get source. Non-functional alias.

alias p="doas pacman -Rsn"
#For doas apt purge. Uninstalls packages and removes configuration
#files. Unlike Debian, this will destroy any orphan dependencies, so
#there is no need to run an "apt autoremove" command

alias r="doas pacman -S"
#For "doas apt reinstall". This alias is redundant as pacman uses the
#same command for installing as for reinstalling (see "i" alias).

alias R="doas pacman -Rs"
#For doas apt remove. Same as the "p" alias, but configuration files
#are preserved.

#TEXT-EDITOR ALIASES:
alias V="doas vim"
#For editing configuration files in Vim

alias v="vim"
#For editing non-root files in Vim

alias Z="doas zile"
#For editing configuration files in Zile

alias z="zile"
#Self-explanatory

#OTHER:
#alias python="python3"
#Useless alias, made when I was trying to build Libreboot roms in
#Debian and/or a Debian-based distro (Libreboot documentation demands
#that the "python" command redirect to python3). On Hyperbola, you do
#not need this alias as the "python" command will open up python3 by
#default. If you are using Debian, be aware that there are packages 
#which redirect python to python3 for you, so you may not need
#to make any dumb python aliases like I tried to do here. UPDATE: I
#have realized the error of my ways and I apologize for calling you
#useless and dumb, alias.
I hereby liberate ALL works of my own posted in the forums, to the fullest extent allowed, under the CC0+a waiver of all other restrictions
Promote love!

2 (edited by anthk 2023-02-04 17:57:08)

Re: My .bash_aliases file :3

Aliasing sh it's a bad idea.

3

Re: My .bash_aliases file :3

I think the "sh" alias can be transmuted into an "m" alias; m for manifest, which has a similar meaning to "show" and is also shorter (only 1 letter) :>

I hereby liberate ALL works of my own posted in the forums, to the fullest extent allowed, under the CC0+a waiver of all other restrictions
Promote love!

4

Re: My .bash_aliases file :3

Some bash functions; they can also be used under mksh or dash (though cf can't be used in dash).

quieterr() { { "${@}"; } 2> /dev/null; }
#Argument passed is executed and errors are discarded

cf() {
       if ! quieterr "${@}"; then
         COMMAND="eval $1"
         shift
           select DESTINATION in $(find -name "${@}");
           do
           $COMMAND $DESTINATION
           break
           done
       fi
       }
#The first argument should be a command, the other arguments are terms
#that will be searched so they one of them can be passed to the command

pac() { pacman -Si \
      | grep 'Name  \|Licenses  \|Download Size  ' \
      | grep -B1 -A1 'CC0\|CC-BY-\..0\|Unlicense\|WTFPL\|ISC\|BSD\|Public-Domain\|Expat\|X11\|MirOS\|custom:Zsh' \
      | grep KiB -B2 \
      | grep 'Name  ' \
      | sed 's/Name            : //'
      }
#Test function that shows permissively-licensed packages with a low 
#size (this is made easier by the fact that packages with a low size are shown in
#kibibytes).

cp() { eval lastPositionalParameter=\$${#}
     if ! [ -d $lastPositionalParameter ]; then quieterr 'mkdir' -p "$lastPositionalParameter" && quieterr rmdir "$lastPositionalParameter"; fi
     command cp -r "${@}"
     }
#Copy files recursively and create the directories needed to house a
#the copied files if the directories don't already exist.

mv() { eval lastPositionalParameter=\$${#} 
     if ! [ -d $lastPositionalParameter ]; then quieterr 'mkdir' -p "$lastPositionalParameter" && quieterr rmdir "$lastPositionalParameter"; fi
     command mv "${@}"
     }
#Same as above, but move instead of copying
I hereby liberate ALL works of my own posted in the forums, to the fullest extent allowed, under the CC0+a waiver of all other restrictions
Promote love!