Pacaur now uses auracle-git. Auracle-git has refused to update for some time but I have been able to continue using pacaur.
Thanks to you I have now looked at the AUR page for auracle-git and found the solution to updating auracle-git.
Here are my zsh alias:
alias make='make -s'
alias orphan='yay -Rcs $(pacman -Qdqt)'
alias mksrcinfo='makepkg --printsrcinfo > .SRCINFO'
Not a lot but the more useful in my geekās life
one of my personal favs is a function for extracting
e() {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjvf $1 ;;
*.tar.gz) tar xzvf $1 ;;
*.tar.xz) tar xJvf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar xv $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xjvf $1 ;;
*.tgz) tar xzvf $1 ;;
*.zip) unzip $1 ;;
*.7z) 7z $1 ;;
*.xz) xz -vd $1 ;;
*) echo āā$1ā cannot be extracted via extract()ā ;;
esac
else
echo āā$1ā is not a valid fileā
fi
}
Now just type e and the name of the archieve -tar.gz - zip whatever. CLI FTW
I think tar archives need only xvf above instead of xXvf (where X means the compression id). Then the function can be shorter.
But thanks anyway for this handy function.
The only thing that bothers me is that it hijacks the name of my function a few posts aboveā¦
lolol sorry man - not my intention
At least I got it confirmed - it IS very useful - even for others
Bash functions (sorry, not an alias!) can de some nice tricks. For example:
# to be added into ~/.bashrc:
bash_prompt_command2()
{
if [ ! "$PWD" -ef "$PWD_previous" ] ; then
PWD_previous="$PWD"
if [ -d ".git" ] ; then
if [ -n "$(grep /endeavouros-team/ .git/config)" ] ; then
echo "**** Here you may want to run command:" >&2
echo "**** git pull" >&2
fi
fi
fi
}
PROMPT_COMMAND=bash_prompt_command2
does this: when I change directory (cd XYZ) and XYZ happens to be my EOS development directory, it reminds me of syncing stuff with github. Note that it checks many things:
- previous working directory was not the same as now
- current folder has a .git subfolder
- check that it actually is the EOS development git folder, other git folders are ignored
Another nice setting (sorry, not alias either!) in e.g. ~/.bashrc is:
FUNCNEST=80
It prevents deep recursion (that may bring your machine down eventually) when you happen to test some faulty bash scripts and programs.
The value could be larger, but anyway, there should be a limit to recursion.
This has saved me lots of time while testing various stuff.
And for ordinary users this shouldnāt cause any issues.
pssst - .zshrc is where functions go
(you know - a little shorter)
Iām still a great bash fanā¦
EDIT: in fact, when writing bash (or zsh) functions, it is possible to write in many styles. Some prefer short (and more cryptic?) code, and some prefer long (but more clear?) code.
How to write ā depends on who is going to see the code, and how it is supposed to be maintained.
Usually I recommend writing clear code, since you never know who is going to maintain the code laterā¦
Here are some simple aliases that I use:
alias ls='ls --group-directories-first' # should be obvious...
alias l='ls -la --ignore=.?*' # like ls -l but doesn't show ".."
alias ll='ls -la --ignore=..' # like ls -la but doesn't show ".."
alias rm='rm -i' # asks confirmation when overwriting
alias cp='cp -i' # asks confirmation when overwriting
alias mv='mv -i' # asks confirmation when overwriting
alias path='echo $PATH' # hello Windows users... ;)
Those ārm -iā like aliases are a bit controversialā¦ Some say they can teach you bad habits, and when you use another system (that you didnāt modify), you may delete files accidentally.
I edited the title. I just didnāt thought of all the great functions that could be implemented in the bashrc, zshrc or fishrc (greetings to @Beardedgeek72).
I just switched to zsh and am taking a look at oh-my-zsh. I like the powerlevel9k or 10k.
NAME
batch - schedule commands to be executed in a batch queue
SYNOPSIS
batch
DESCRIPTION
The batch utility shall read commands from standard input and schedule them for execution in a batch queue. It shall be the equivalent of the command:
at -q b -m now
where queue b is a special at queue, specifically for batch jobs. Batch jobs shall be submitted to the batch queue with no time constraints and shall be run by the system using algorithms, based on unspecified factors, that may vary with each invocation of batch .
[[XSI](javascript:open_code(āXSIā))] Users shall be permitted to use batch if their name appears in the file at.allow which is located in an implementation-defined directory. If that file does not exist, the file at.deny , which is located in an implementation-defined directory, shall be checked to determine whether the user shall be denied access to batch . If neither file exists, only a process with appropriate privileges shall be allowed to submit a job. If only at.deny exists and is empty, global usage shall be permitted. The at.allow and at.deny files shall consist of one user name per line.
OPTIONS
None.
OPERANDS
None.
STDIN
The standard input shall be a text file consisting of commands acceptable to the shell command language described in Shell Command Language .
INPUT FILES
[[XSI](javascript:open_code(āXSIā))] The text files at.allow and at.deny , which are located in an implementation-defined directory, shall contain zero or more user names, one per line, of users who are, respectively, authorized or denied access to the at and batch utilities.
ENVIRONMENT VARIABLES
The following environment variables shall affect the execution of batch :
LANG
Provide a default value for the internationalization variables that are unset or null. (See XBD Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.)
LC_ALL
If set to a non-empty string value, override the values of all the other internationalization variables.
LC_CTYPE
Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments and input files).
LC_MESSAGES
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error and informative messages written to standard output.
LC_TIME
Determine the format and contents for date and time strings written by batch .
NLSPATH
[[XSI](javascript:open_code(āXSIā))] Determine the location of message catalogs for the processing of LC_MESSAGES.
SHELL
Determine the name of a command interpreter to be used to invoke the at-job. If the variable is unset or null, sh shall be used. If it is set to a value other than a name for sh , the implementation shall do one of the following: use that shell; use sh ; use the login shell from the user database; any of the preceding accompanied by a warning diagnostic about which was chosen.
TZ
Determine the timezone. The job shall be submitted for execution at the time specified by timespec or -t time relative to the timezone specified by the TZ variable. If timespec specifies a timezone, it overrides TZ. If timespec does not specify a timezone and TZ is unset or null, an unspecified default timezone shall be used.
ASYNCHRONOUS EVENTS
Default.
STDOUT
When standard input is a terminal, prompts of unspecified format for each line of the user input described in the STDIN section may be written to standard output.
STDERR
The following shall be written to standard error when a job has been successfully submitted:
ājob %s at %s\nā, at_job_id , < date >
where date shall be equivalent in format to the output of:
date +ā%a %b %e %T %Yā
The date and time written shall be adjusted so that they appear in the timezone of the user (as determined by the TZ variable).
Neither this, nor warning messages concerning the selection of the command interpreter, are considered a diagnostic that changes the exit status.
Diagnostic messages, if any, shall be written to standard error.
OUTPUT FILES
None.
EXTENDED DESCRIPTION
None.
EXIT STATUS
The following exit values shall be returned:
0
Successful completion.
0
An error occurred.
CONSEQUENCES OF ERRORS
The job shall not be scheduled.
The following sections are informative.
APPLICATION USAGE
It may be useful to redirect standard output within the specified commands.
EXAMPLES
- This sequence can be used at a terminal:
batch sort < file >outfile EOT
- This sequence, which demonstrates redirecting standard error to a pipe, is useful in a command procedure (the sequence of output redirection specifications is significant):
batch <<! diff file1 file2 2>&1 >outfile | mailx mygroup !
RATIONALE
Early proposals described batch in a manner totally separated from at , even though the historical model treated it almost as a synonym for at -qb . A number of features were added to list and control batch work separately from those in at . Upon further reflection, it was decided that the benefit of this did not merit the change to the historical interface.
The -m option was included on the equivalent at command because it is historical practice to mail results to the submitter, even if all job-produced output is redirected. As explained in the RATIONALE for at , the now keyword submits the job for immediate execution (after scheduling delays), despite some historical systems where at now would have been considered an error.
FUTURE DIRECTIONS
None.
SEE ALSO
CHANGE HISTORY
First released in Issue 2.
Issue 6
This utility is marked as part of the User Portability Utilities option.
The NAME is changed to align with the IEEE P1003.2b draft standard.
The normative text is reworded to avoid use of the term āmustā for application requirements.
Issue 7
The batch utility is moved from the User Portability Utilities option to the Base. User Portability Utilities is now an option for interactive utilities.
SD5-XCU-ERN-95 is applied, removing the references to fixed locations for the files referenced by the batch utility.
i also have the funtion to make ābeepā
beep(){
( speaker-test -t sine -f 1000 )& pid=$! ; sleep 0.5s ; kill -9 $pid
}
You can run a command like updateing your system and get warned with the beep after itās all ready like
sudo pacman -Syu && beep
or
sudo pacman -Syu; beep
(beeps in case of error or canceling too)
You can add all these as an alias.
How about having double beep at error:
sudo pacman -Syu && beep || { beep ; sleep 1; beep; }
My .aliases file, consisting of general purpose aliases or functions in the first half and (PHP) development in the second half
#
# ~/.aliases
#
alias ins="sudo pacman -S"
alias rem="sudo pacman -R"
alias remd="sudo pacman -Rsnc"
alias up="sudo pacmatic -Syu"
#locate orphan pacnew files
alias pacnew="sudo find /etc/ \( -name \*.pacnew -o -name \*.pacorig -o -name \*.pacsave \)"
alias s="poweroff"
#reset the network adapter by reloading its driver. useful if network misbehaves after resume from suspend
alias netup="sudo modprobe -r r8168 && sudo modprobe r8168"
### UTILS ###
#edit a file
alias ed="setsid medit"
alias edit="setsid medit"
#edit a file as root
function sedit {
(sudo medit "$1" &)
}
#boot to EFI Setup, indispensible when fastboot is active, as you can't get into EFI Setup by holding a key pressed
alias firmware="systemctl reboot --firmware-setup"
#rip audio off youtube and save it in the current directory
alias dl="youtube-dl -x --audio-format 'm4a' "
alias dlmp3="youtube-dl -x --audio-format 'mp3' "
#DEVELOPMENT HELPERS
#--------------------------------------
#handy for uses like 'ap restart', 'ap stop', 'ap start'
alias ap="sudo apachectl"
#HOSTS file manipulation
#view hosts content
function vhost(){
echo --------------------------------------------
cat /etc/hosts
echo
echo --------------------------------------------
}
#swap hosts files, handy for working locally on dev domains,
#then switching to real domains to test the deploy live
function chost {
set -e # stop running if we encounter an error
#at first run simply creata a copy of the existing hosts file.
# the new file should be edited and 127.0.0.1 devdomain.com lines should be added to it
# apache should also be configured to handle these domains
if [[ ! -f /etc/hostssecondary ]]; then
sudo \cp /etc/hosts /etc/hostssecondary
return
fi
sudo \mv -f /etc/hosts /etc/hoststempname
sudo \mv -f /etc/hostssecondary /etc/hosts
sudo \mv -f /etc/hoststempname /etc/hostssecondary
set +e
echo --------------------------------------------
cat /etc/hosts
echo
echo --------------------------------------------
}
#Toggle xdebug on or off (xdebug on slows down php development)
#rotates 2 ini files, one of them having 'zend_extension=xdebug' commented out
#Both files contain this on a line:
#/ XDEBUG OFF /# or #/ XDEBUG ON /#
#so the script finds this line and outputs it so you know if it's on or off
function xdebug {
set -e # stop running if we encounter an error
if [[ -f /work/LAMPP/.config/php.ini.alt ]]; then
mv -f /work/LAMPP/.config/php.ini /work/LAMPP/.config/php.ini.tmp
mv -f /work/LAMPP/.config/php.ini.alt /work/LAMPP/.config/php.ini
mv -f /work/LAMPP/.config/php.ini.tmp /work/LAMPP/.config/php.ini.alt
set +e
echo --------------------------------------------
echo
cat /work/LAMPP/.config/php.ini | grep "#/ XDEBUG"
echo
echo restarting apache...
ap restart
echo done
echo --------------------------------------------
fi
}
#function to quickly create a database, a corresponding user and grant access to the database to that user
function mkdb() {
echo
if [ 2 -gt $# ] ;then
echo "mkdb - invalid parameters"
echo "** usage: mkdb database_name [user_name] password"
echo "** if user_name is not specified database_name will be used also for user_name"
else
db_name=$1
if [ $# -gt 2 ]
then
user_name=$2
pass=$3
else
user_name=$1
pass=$2
fi
echo
echo "Creating database '$db_name' and user '$user_name' and granting access to database to the new user."
mysql -u root --execute="CREATE USER IF NOT EXISTS '$user_name'@'localhost' IDENTIFIED BY '$pass';GRANT USAGE ON *.* TO '$user_name'@'localhost' REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;CREATE DATABASE IF NOT EXISTS $db_name;GRANT ALL PRIVILEGES ON $db_name.* TO '$user_name'@'localhost';"
fi
echo
}
function dbimport(){
echo
echo "******* Import DB Script ********"
if [ 2 -gt $# ] ;then
echo "** ${FUNCNAME[0]} - invalid parameters"
echo "** usage: ${FUNCNAME[0]} {database_name} {file_to_import.sql}"
else
db_name=$1
file_name=$2
if [ -f $file_name ]
then
echo
echo "Importing file into database '$db_name'"
mysql -u root -p $db_name < $file_name
else
echo "Invalid file: $file_name"
fi
fi
echo
}
#dumps the content of a database to a file named {database_name}.sql in the current working folder
function dump(){
mysqldump -u root $1 > $1.sql
}
alias showdb="mysql -uroot -p --execute='show databases'"
Back again, these are the ones I am using now:
alias mirrors="sudo reflector --verbose --protocol https --country Germany --country Sweden --latest 10 --sort rate --save /etc/pacman.d/mirrorlist"
alias update="mirrors && yay -Syyu --cleanafter && paccache -rk1"
alias downgrade="mirrors && yay -Syyuu --cleanafter && paccache -rk1"
alias cleanup="yay -Yc && yay -Rns (pacman -Qqdt)"
Added two after the welcome app was introduced, btw:
alias eosw="eos-welcome --enable"
alias eosd="eos-welcome --disable"
Modified my āUpdateā alias to account for auto-snapshot with timeshift (there is an AUR package for that: timeshift-autosnap with very sane defaults (it autocleans, only keeps three snapshots at all times). I had to split my update into two parts instead of just running
yay -Syyu
ā¦since yay does not trigger the pacman hook that starts the auto snapshot.
āMirrorsā is another alias that just picks the 10 latest updated mirrors in Scandinavia / Germany and ranks them according to speed. In effect I am chaining aliases within aliases.
Also keep in mind I run Fish shell, so my aliases look different than yours. The actual command can just be copied and pasted into a Bash alias tho, of course.
# Defined in - @ line 1
function update --description 'An alias for -Syyu and trimming pacman cache. Auto-refreshes mirrorlist first.'
mirrors && sudo pacman -Syyu && yay -Syyua && sudo paccache -r $argv;
end
By far not as sophisticated as the other posts here, but hereās one I use very often:
alias hg=āhistory 1 | grep $1ā
Allows me to easily find previous commands. E.g. the complicated pacman command I used two months ago:
hg pacman
How about a general scripts & tips thread with ideas and little helpers which can make our Arch/EndeavourOS live easier?
To go by example hereās one I find quite helpful:
Integration of Virustotal into Dolphin file manager
- Create account on Virustotal to get access to the API
- Install virustotal CLI tool
- Add your new API key to /etc/virustotal.conf file
- Add script and desktop file to provide easy access to virustotal
This script can be run via CLI and with a Desktop file also from Dolphin
#!/bin/bash
# Prerequisits:
# - virustotal CLI app installed: "yay -S virustotal"
# - Create virustotal API key via registring on their website: https://www.virustotal.com/gui/join-us
# - Virustotal API key added to /etc/virustotal.conf
# - Optional: Corresponding KDE service menu copied to ~/.local/share/kservices5/ServiceMenus/
Divider1="##############################################################################"
Divider2="------------------------------------------------------------------------------"
version="1.0.0"
echo $Divider1
echo "Virustotal file checker v. $version"
if [ "$1" == "" ]; then
echo "No file name given"
echo "Usage: virustotal <filename>"
if (( SHLVL < 2 )) ; then
read -p "Press any key to close window" answer
fi
else
echo "Uploading $1 to Virustotal website..."
echo $Divider2
virustotal "$1"
echo $Divider2
if (( SHLVL < 2 )) ; then
read -p "Press any key to close window" answer
fi
fi
The desktop file needs to go to ~/.local/share/kservices5/ServiceMenus/
Make sure you adjust the path and name of the script in this line
Exec=konsole -e ~/scripts/virustotal.sh %F
to fit your requirements as far as the name and location of the bash script is concerned.
Hereās my viruscheck.desktop:
[Desktop Entry]
Actions=virustotal
MimeType=all/all;
ServiceTypes=KonqPopupMenu/Plugin
Type=Service
X-KDE-Priority=TopLevel
X-KDE-StartupNotify=false
X-KDE-Submenu=Virus check
[Desktop Action virustotal]
Exec=konsole -e ~/scripts/virustotal.sh %F
Icon=scanner
Name=Send to Virustotal
Hereās the result:
In bash, another way to use old commands is to use the UP and DOWN arrow keys. With a proper configuration (as recent EndeavourOS installs are), you can, in terminal, write some first letters of the command you want back, and then hit the UP-arrow key (maybe several times). Try also DOWN-arrow key and see what happens!
Those hits of arrow keys bring back old commands in history order. You can even modify the found command to create a new command into the history.
So, the proper configuration (in file ~/.bashrc) is:
bind '"\e[A":history-search-backward' bind '"\e[B":history-search-forward'
If you donāt have those bind lines in your ~/.bashrc, you can copy them from here.
NOTE: be careful to copy the bind lines exactly as they are above (especially quotes). Otherwise they wonāt work.