Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.
/ Handyscripts Public archive

Handy POSIX(mostly) scripts I made for personal use.

License

Notifications You must be signed in to change notification settings

xplshn/Handyscripts

Repository files navigation

Handyscripts

These should work on most POSIX systems. I try to minimize dependency on sucky software like that made by the FSF/GNU. If these script are not suckless, or do not work with any POSIX compatible system, please let me know, also, if you make changes, I'd be grateful if you made a PR.


  • Setup & Config

  1. Clone to /usr/local/bin and OR/AND any place in your $PATH
  2. Set executable bit with chmod +x.

  • Baker Rreceives a file as an argument and copies it to <file>.bak, when invoked with -R it moves <file>.bak to <file>.
  • When using -R do not suppply files ending in .bak, the script automatically detects them, if you want, you can do .bak.bak by using "baker .bak", though I do not recommend you do that, it quickly becomes confusing. Keep in mind that -R does not switch places with and .bak, it moves .bak to .

  • It can Run(without installing), Install, Remove, List or give Info about programs or Search them (Fuzzy search that matches agains descriptions and package names).
❯ Usage: bdl {run|install|remove|search|info|list|tldr} <PACKAGE_NAME>

curl -qfsSL "https://raw.githubusercontent.com/xplshn/Handyscripts/main/bdl" | bash -s -- {OPTIONS_HERE}
#Example
curl -qfsSL "https://raw.githubusercontent.com/xplshn/Handyscripts/main/bdl" | bash -s --  run neofetch
  • The Run option runs programs from /tmp, it caches them to a file, so if you run a program with the flag run more than one time, the second time it will not have to download the program anymore, if more than 40+ programs are cached, the cache deletes the first 40+ programs. It uses TMPFS for this behavior. Please edit the script to your likings, the first part of it contains variables you can change.
  • It is not POSIX, but it works under BASH and shells which support extended POSIX. If you know how to fix that, how to make it suck less, I'd be grateful if you'd make an issue or a PR. For now, in the first run it will bootstrap bash by grabbing the binary from the Buildbase repo and then on subsequent runs it will use bash. The syntax is POSIX but MIGHT rely on undefined behaviour (When running under SH).
  • Implemented in 363LOC! # Could be smaller but has many features.
  • Rewritten in Golang: bigDL asciicast

  • ccat (ColorCat) Wrapper for cat that uses source-highlight to highlight text whenever a deffinition file matches the content of the text. Really handy! I recommend doing an alias, since it behaves exactly like cat.

  • catservice | dogservice catservice and dogservice deliver fresh cat/dogs photos to your terminal (See the script and API documentation to change sizes, breeds, etc. Add to your shell's rc for maximum productivity)

image


  • OG++4.8 Wrapper for using an online compiler's API, currently, it does not support stdin or many libraries apart from those that come with g++. You can edit the og++4.8 script and change its version in the "compiler_cmd" variable. It is very OG.

  • The unnoficial API it uses to connect to tiktok's API can only parse 300 characters per request. In this script that is contemplated and so the text is cut into parts. You can also pass the voice you want to use, like this: ttts "Gangzta!" "en_us_009". Or use it along with TGPT and whisper.cpp's "command" tool to make an assistant that can even run commands(using tgpt -s you can ask tgpt to produce commands).
  • See voices_ttts.md

  • whoch REALLY HANDY when working with a big PATH variable, or with "replacing" commands, whoch receives a command as an argument and acts the same way as which, however, whoch prints out an ordered list of where that command is in your PATH.
  • If you have /usr/local/bin/cargo and /usr/bin/cargo, if whoch were invoked with "cargo" as argument it'd print out this:
$ whoch cargo
#output
/usr/local/bin/cargo
/usr/bin/cargo
  • pelf PELF or rather, Pack an ELF is a utility that creates a bundle of a dynamic binary, it takes a binary and bundles its dependencies into a single, executable file. Along with optional directories, binaries and libraries, which are all accesible from the packed binary, as they are in its LD_LIBRARY_PATH and PATH. This allows for creating wrappers so that you can pack an entire C toolchain into a single executable, which is something I've done using Zig's static releases.
  • It needs tar and base64. It is POSIX2008 compatible. It has proven to work on Alpine and .blobs generated across other systems work too (There might be some exceptions due to ABI differences.) of the same libc, one may use patchelf to change the interpreter prior to packing the binary. The compression can be changed by modifying the script, keep in mind that using base64 will expand the size of data by 37.6%, one can also use ascii85 which only expands size by 13%.
$ pelf $(which chocolate-doom) ./chocolate-doom.blob # The name can not be set arbitrarily.
$ ./chocolate-doom.blob
                         Chocolate Doom 3.0.1
Z_Init: Init zone memory allocation daemon. 
zone memory: 0x7fd294494020, 1000000 allocated for zone
Using /tmp/.local/share/chocolate-doom/ for configuration and saves
V_Init: allocate screens.
M_LoadDefaults: Load system defaults.
saving config in /tmp/.local/share/chocolate-doom/default.cfg
Game mode indeterminate.  No IWAD file was found.  Try
specifying one with the '-iwad' command line parameter.
# as you can see, it works. Most programs can be packed this way, even graphical ones ; Some others may require you to create wrappers, to add extra binaries or libraries which do not appear in ldd's output.
# I've also managed to pack my window manager along with a few X utils into a single file (programs packed alongside each other can be accessed from the main program's PATH)
# An example you can try to see the capabilities of PELF is to pack the xfce4-terminal into a single binary, ofc PELF won't track python dependencies, or schemas or other misc files a program may need, but you can still use the --add-arbitrary functionality and create a wrapper for the main binary, then add the real binary with --add-binary.
# You can also create "development boxes", a binary which when executed launches a shell with a custom PATH and LD_LIBRARY_PRELOAD, the dev box can contain Golang, Make, Zig C as a portable C compiler, Rust's Cargo, etc, all by creating a wrappper that modifies some env variables (e,g for Go; GOROOT="$(dirname "$devbox_bindir")/go") and using --add-arbitrary to add the necessary folders which contain the programs' files
  • xpointerkeys Enables X's pointerkeys feature "setxkbmap -option "keypad:pointerkeys".

About

Handy POSIX(mostly) scripts I made for personal use.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages