83 private links
An good example of how to lock the computer and send it to sleep on a timer.
Uses swaylock
and wayidle
, so primarily made for wayland.
When archlinux switches to a new python base version, the AUR packages installed with an AUR helper do not automatically re-install themselves for the new environment.
End result is that most AUR python-dependent packages now error out with missing module errors (since they are looking in the old python env).
To show packages which have any of their files located in the python lib directory (i.e. all python-dependent packages):
pacman -Qoq /usr/lib/python3.8/
Here's how to find and reinstall packages depending on a certain base package or path (take care of how to input either path or package!):
pacman -Qoq /usr/lib/python3.8/ | paru -S --rebuild -
pactree -r qt-base --depth 1 -l | paru -Ta | paru -S - --rebuild
yay -S --rebuildall --noconfirm $(yay -Qqo /usr/lib/python3.8/)
Very nice list of bash-internal functionality. Mirrors the 'pure-sh-bible' by dylanaraps.
Showing how to combine short (-h
) posix options with long-form (--help
) gnu-like options while using getopts.
It seems overkill for smaller applications which are probably best off with a simple snippet like:
while :; do
case "$1" in
-f | --file) BEMOJI_CUSTOM_LIST="${OPTARG}"; shift 2 ;;
-h | --help) usage 0 ;;
-p | --private) bm_private_mode=true; shift ;;
-v | --version) version ;;
-*) usage 1 ;;
*) break ;;
esac
done
for option gathering, but for more complex setups this could be the way to go.
What is the equivalent of Python dictionaries but in Bash (should work across OS X and Linux)?
Super simple explanation and a variety of updating and traversing them. Different ways of achieving all of these ideas also listed in easy-to-digest format here: https://www.xmodulo.com/key-value-dictionary-bash.html
One of, perhaps the best single source of tutorials (a meta-list if you want) for bash scripting.
Parsing HTML at the command line. An html equivalent to jq, kind of
The base16 theme manager I always wanted. Takes a base16 theme, an application configuration file (like for alacritty, vim, qutebrowser, etc) and applies the theme to the file considering certain rules.
I tried to achieve it in my dotfiles as styler but it's a hacky bash script and this seems faster, more thought-through and exactly what is needed to flexibly theme any applications.
Basically, a faster more extensible pywal.
A wonderful little one-liner to grab all VARIABLE=CONTENT lines from an environment file and automatically add them to your current environment.
In its simplest form:
export $(cat /your/file/env | xargs)
But there are variations for potential spaces in the var content, only setting them (eval) for a single command and automatically unsetting variables again,
If you have a script that needs to keep up a single infinite pipeline but want to use sed (or grep) with it, simply use:
sed -u <mysedstuff>
to flush the pipes more often (usually means after every line)
or tail -f file | grep --line-buffered my_pattern
.
You can also use a command called stdbuf, see here https://unix.stackexchange.com/a/25378 in case you need it for other programs which do not support such a flushing mode.
Burgeoning linter for zsh scripts. Akin to shellcheck but specific to zsh. Developed by a trustworthy individual, so even if early days is probably fruitful to keep an eye on.
Tilde (~) goes beyond just denoting the user's home directory in bash:
~fred/foo
# The subdirectory foo of the home directory of the user fred
~+/foo
# $PWD/foo
~-/foo
# ${OLDPWD-'~-'}/foo
~N
# The string that would be displayed by ‘dirs +N’
~+N
# The string that would be displayed by ‘dirs +N’
~-N
# The string that would be displayed by ‘dirs -N’
To print e.g. newline characters with bash printf which interprets the characters EVEN FROM A VARIABLE, do printf "%b" "my\nnewline\nvariable"
.
printf's %b
format specifier was meant specifically to replace echo -e
(actually, the XSI extension to echo which calls for special interpretation of the arguments by default. -e was never specified and is disallowed by POSIX.), and is identical in virtually every way including a few differences from $'...' and the format string argument to printf.
$ \curl -L https://get.rvm.io | bash -s stable --ruby
There's no error, it's a little hack to avoid using a curl shell alias if any exists.
This works too :
'curl' (...)
"curl" (...)
/usr/bin/curl (...)
command curl (...)
command -p curl (...)
To print every N th line, use
sed -n '0~Np'
It is written in the form first~step(print). For example, to copy every 5th line of oldfile to newfile, do
sed -n '0~5p' oldfile > newfile
sed -n '2~5p' oldfile
would print lines 2, 7, 12, 17, 22, 27, …, up to the end of the file.
Note: This approach requires GNU sed, as the first ~step address form is a non-portable extension. (Some old versions of GNU sed may require the 5~5 form as opposed to the 0~5 form.)
A detailed run-down of the differences between [ condition ] and [[ condition ]] in bash programming.
A script made to upload and share things, copying the share link to your clipboard, with simple logic.
Official repository for community contributed blocklets.
scripts and helper modules for i3blocks - but can presumably be adapted for polybar/yambar/lemonbar etc
Exhaustive list, with pros and cons, of access to nextcloud files.
Includes a little 'push' function to send stuff directly to your nextcloud folders which could be adapted to different use cases.
Not mentioned: S3 primary storage on Nextcloud
Uses an .ics
file (or a simulated file, through a HEREDOC, see solutions here ) to send it through curl as a data stream and thus bring it into Nextcloud.