Useful and "Use Less" Scripts

Thanks for sharing.

The idea behind the scripts above is to minimise extra packages that aren’t already present in most Arch Linux systems. So, in this case, there is a preference on utilising tools like:
ffmpeg, python, pacman, notify-send, a terminal, etc.

When it comes to aliases, I have quite a few myself. I rarely use anything but aliases when using a terminal.

Example:

syu && yy && fup && gpa

This is a combined update that I run. It does this:

sudo pacman -Syu && yay -Sua && flatpak update && cd Appz/GIT_PKGS/paru-git/; git pull; cd; cd Appz/GIT_PKGS/qimgv/; git pull; cd; cd Appz/GIT_PKGS/fsearch/; git pull; cd

The “gpa” alias only checks if there are updates available, as I manually apply those updates after reviewing what’s been changed. I use my “gl” alias for this.



  • Converted thread to a Wiki
  • Added “Open Links in FreeTube (Wayland)”
  • Added some of my terminal shell aliases.
  • Updated “ImageMagick Grid/Collage From Selected Images”.
  • Updated “Merge Selected Images Horizontally/Vertically Using ImageMagick”.
    • Both now use a dark background and try to center images relative to each other.
  • Converted “cup” alias to a function:
### Function to send checkupdates and paru -Qua to a file then open it in micro
function cup
  set syu_date_format (date +"%Y-%m-%d_%H-%M-%S")
  set syu_log_name "path/to/new/log/file/syu-$syu_date_format.sh"
  # The "checkupdates" command adds some unwanted text. Use "sed" to remove them.
  checkupdates | sed 's/\x1b\[[0-9;]*m//g' > "$syu_log_name"
  paru -Qua >> "$syu_log_name"
  sleep 0.1
  micro "$syu_log_name"
  # Remove the last two lines above if you don't need to see the output.
  # They can be replaced with syu && yy / syu && yy && fup to update immediately.
  # This is good for logging the available updates before updating.
end

→ The purpose of this file is just for reference to updates that were/are available prior to updating. Reference in case of a buggy update, that is. The file is much cleaner that pacman’s log file, so I prefer it. I found myself manually creating this file before updates, so I decided to automate the file creation aspect.

  • Updated the “rnsu” function.
    • Now it is more robust using a fuzzy search, while also checking the .cache and .local/share directories for both folders and files matching part of the package name. Be careful with this and pay attention to which folders/files are being sent to the trash. In any case, you can just restore the files as they are not permanently deleted.
function rnsu
    if test (count $argv) -eq 0
        echo "Usage: rnsu package_name"
        return 1
    end

    set package_name $argv[1]

    # Run the pacman command
    sudo pacman -Rnsu $package_name

    # Ask the user if they want to remove the related files
    read -P "Would you like to remove the related configs for \"$package_name\"? (y/n): " response

    if test "$response" = "y"
        set directories ~/.config ~/.cache ~/.local/share
        set found_items 0

        for dir in $directories
            set -l matches (find $dir -maxdepth 2 -iname "*$package_name*")
            if test (count $matches) -gt 0
                set found_items 1
                for match in $matches
                    echo "Found: $match"
                end
            end
        end

        if test $found_items -eq 1
            read -P "Do you want to move these items to the trash? (y/n): " confirm
            if test "$confirm" = "y"
                for dir in $directories
                    set -l matches (find $dir -maxdepth 2 -iname "*$package_name*")
                    for match in $matches
                        echo "Moving to trash: $match"
                        trash -v $match
                    end
                end
                echo "Related files and folders for \"$package_name\" have been moved to the trash."
            else
                echo "No items have been moved to the trash."
            end
        else
            echo "No related files or folders found for \"$package_name\"."
        end
    else
        echo "No files or directories have been removed or sent to the trash."
    end
end
  • Updated Fish “cup” (check for updates) alias/function.
    • Now it no longer creates a file if there are no updates available, and instead prints, “No updates found.” in the terminal.
  • Added “Unison Sync Operations + Fish Alias” script.
  • Modified “Update Notifier” script so that it now uses yay -Qua instead of paru -Qua.
    • It seems yay has finally added an equivalent yay -Qua check that only checks for updates without also trying to apply the updates.
  • Added my MPV config. More functions here: https://mpv.io/manual/stable/
  • Add the following lines for Dolphin Service Menus: the first prevents the action from going into a submenu, and the second sets a minimum requirement for number of selected files. Both are good if you work with images often, but don’t want a cluttered context menu.
[Desktop Entry]
X-KDE-Priority=TopLevel
X-KDE-MinNumberOfUrls=2
2 Likes