Share your alias AND/OR function

reflector supports country names (must be quoted if it contain spaces!) as well as country codes. For example,

  reflector -c "United States" -c UK 
1 Like

Reflector AFAIK does not support the idea of continents.

For Antergos I created an app called reflector-antergos that had a notion of “continents” or “named countrygroups”. But after all that idea didn’t seem so great, so I didn’t support it in reflector-simple nor reflector-auto.

add - commit - push in one go

function acp() {
git add .
git commit -m “latest update”
git push
}

This thread contains so much useful information that I am bookmarking it. This is the real power of ‘Community’.

8 Likes

This item is more of a script than a function, but it seems to me that it fits here better than in a wiki entry! Essentially, it automates the Arch “Wayback Machine” or, as I have called it ShiftTime :grin: What this ‘Machine’ does essentially, is take your system back to the date that you specify - by reverting, or downgrading all the packages that have been updated after that date.

I decided I would try to make the script accessible, so here I will describe setting it up as a button in the Welcome app - although of course it would work fine if just called from the command line. Or, of course, you could carefully read the Archwiki entry on reverting your package status to a previous date, and follow the steps as they describe them.

Essentially, there are 2 pieces to the setup - the script itself, and the .desktop file that describes it. The locations they need to be in may have to be created if they do not already exist:

  1. $ mkdir -p ~/.local/share/applications
    This command will create this directory if it does not already exist. The following .desktop file goes in it - with the name ShiftTime.desktop suggested.
.desktop

[Desktop Entry]
Name=ShiftTime
Comment=Revert pkg state to a previous date.
GenericName=Revert pkg state to a previous date
Exec=RunInTerminal shifttime
Icon=system-software-install
Type=Application
NoDisplay=true
StartupNotify=true
Categories=Utility

  1. Then you create a file called shifttime with the following content:
ShiftTime script
#!/bin/bash
# This script enables an after-the-fact timeshift equivalent for Arch systems
# Give it a date (as in 2020-09-20) and it will use the Arch archive repos 
# to revert to that date's package state.
#
# 21 September 2020 - freebird54

echo "Select the date to revert your packages to. Press ENTER when ready"
read
REVERTDATE=`yad --calendar --date-format=%C%y/%m/%d`
echo " "
echo "Packages will be reverted to the state they were in on $REVERTDATE."
echo " "
echo "Ready to copy /etc/pacman.d/mirrorlist to backup"
sudo mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup_st
# building the repo entry for the specified date, and making it the mirrorlist temoporarily
echo "Server=https://archive.archlinux.org/repos/$REVERTDATE/\$repo/os/\$arch"  > /tmp/mirrorlistchk
sudo cp /tmp/mirrorlistchk /etc/pacman.d/mirrorlist
rm /tmp/mirrorlistchk
echo " "
echo "Here is the reversion mirrorlist"
cat /etc/pacman.d/mirrorlist
echo "If the date shown is correct please press ENTER"
read
echo " "
# run the 'downdate' command
sudo pacman -Syyuu
echo " "
echo "Restoring the backup mirrorlist..."
sudo cp /etc/pacman.d/mirrorlist.backup_st /etc/pacman.d/mirrorlist
echo " "
echo "Done. Press ENTER to exit."
read
  1. Make the file executable:
    $ chmod +x shifttime

  2. Copy the file to somewhere on your path:
    $ sudo cp shifttime /usr/bin

  3. Start up the Welcome app, choose the ‘Tips’ tab, and click on the Personal Command drag&drop button - which will open up a window. Open your File Browser, navigate to ~/.local/share/applications, and drag ShiftTime.desktop over to and drop it in the window that Welcome opened up.

  4. That’s it! Once Welcome comes back, it will have a Personal Commands tab (if it didn’t already) and ShiftTime will be waiting for you to click on the button showing its name to run the script. Pacman will be called to determine which packages need to be downgraded to revert your system to the way it was at the date you specified. You can interact with pacman as usual to decide whether or not to proceed with the downgrade. The pacman ‘control’ files that the script modifies will be returned to normal after the modified ones have been used.

Again, this does nothing you could not do directly yourself by following the Archwiki - but it saves typing (or looking it up again) if you happen to need it. This also shows how easy it is to add your own ideas to the buttons on the Welcome app! Essentially, for most things, all you need to do is create an appropriate .desktop file, and drop it in the drag&drop window. Enjoy, and I hope you don’t need it.

10 Likes

A really simple way to perform a full system update including Arch + AUR + Flatpak packages

alias YOUR_ALIAS='yay && flatpak update'

It combines ‘yay’ (that will perform ‘yay -Syu’ wich is similar to pacman -Syu + updating packages from the AUR) and ‘flatpak update’ (wich will update flatpak packages).

1 Like

It might be a good idea to add one thing:

flatpak uninstall --unused

To auto-clean the cache for flatpak since it doesn’t do that automatically. The --unused flag means it will only uninstall old packages no longer in use. So I suggest amending your alias like so:

alias YOUR_ALIAS="yay && flatpak update && flatpak uninstall -unused"

Providing you use flatpak of course :slight_smile:

2 Likes

I think it is more sensible not to install flatpaks in the first place :wink: SCNR …

3 Likes

Thanks for the addition, I’ll do it right away!

1 Like

If you have Flatpak installed does yay not update them?

Maybe it’s a relatively new feature? I could swear It doesn’t, but I’ll have to try.

No, it doesn’t.

The reason i asked is because certain pamac versions have flatpak and yay updates AUR so just wondered not that i use flatpaks or want to. :wink:

pamac supports both snap and flatpak. pamac is much more than an AUR helper at this point. It is really Manjaro’s all in one package manager.

I’m just surprised that yay hasn’t moved in that direction. I don’t use flatpaks or snaps and don’t intend to unless i was using a different distro. I don’t particularly want to have to use a bunch of different tools to update.

1 Like

This line I like for bash script ::: one folder to run from, anywhere on the system.

# Makes the script more portable #####################################################
######################################################################################
readonly DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
######################################################################################

Interesting, but what is the use case for that script?
Usualy I have my custom scripts dumped inside ~/.local/bin so I want to apply the script on the “current” directory and not ~/.local/bin.

Here is, without doubt, the best alias ever: Post your handy utility scripts! - #125 by Kresimir

It has completely changed the way I use terminal.

Example readonly DIR.

############################################################
# Makes the script more portable ###########################
readonly DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
############################################################

# konsole pacman update
readonly PACUP="${DIR}/002-pacman-konsole"

# konsole yay update aur
readonly YUPK="${DIR}/003-yay-konsole"
readonly YUP="sudo pacman -Qu"

# Manuals and tech
# readonly manned="${DIR}/manned"
# readonly wiki="${DIR}/wiki.sh"

# txt files for cat
readonly DBL="${DIR}/dblock"
readonly DN="${DIR}/done"
readonly OK="${DIR}/ok"
readonly Tpack="${DIR}/total-pack-upd"

##### Install pack list / remove pack list #################

# Search and install one package with yay
readonly INS1="${DIR}/search.sh"
# remove single package
readonly RM1="${DIR}/remove.sh"

# Add / Remove package to generate list
readonly INL="${DIR}/004-add-install-list"
readonly RML="${DIR}/005-add-remove-list"

# Install / Remove Pack List
readonly rmlist="${DIR}/007-remove-list.sh"
readonly inlist="${DIR}/008-install-list.sh"

###
# Install / Remove . TXT
readonly Rrmlist="${DIR}/remove-list.txt"
readonly Iinlist="${DIR}/install-list.txt"

etc .....

Maybe I should have said. Makes a script more portable when refer to external files included inside the folder.
With the line you can move the folder with the files where ever you want.

1 Like