Some shell utility scripts. All scripts are written in either POSIX shell or c++ and so should be fairly portable.
Note: make will strip extensions when installing to executables will not have
.sh
or .out
at the end
- shell
- tested on bash, dash and zsh
- needed for
*.sh
- make
- needed for everything
- c++ compiler with support for c++ 20
- tested with gcc 11.1 and 11.2
- if you have a c++ compiler that is not
/usr/bin/c++
, you can specifyCC
macro inconfig.mk
- needed for
*.cpp
- clang-tidy
- needed for
ctfix.sh
- needed for
- gpg, tar
- needed for
decryptdir.sh
andencryptdir.sh
- needed for
- curl
- needed for
dict.sh
- needed for
- bat
- needed for
wbat
andobat
- needed for
- grub
- needed for
update-grub.sh
- needed for
- xprop
- needed for
wminfo.sh
- needed for
- pdftotext
- needed for
pdfcounter.sh
- needed for
- creates a backup of the file (or directory) passed to it as the first argument.
- backed up file is called
ORIGINAL_NAME.bak
- removes
aux
bcf
andlog
files produced by pdflatex for a specific target - can remove the pdf too
- checks color capabilities of a terminal by printing all colors
- copy directory structure without the files
- fixes c/c++ files with clang-tidy
- decrypts the tarball, then decompresses it.
- deletes the encrypted tar and the unencrypted tar.
- takes 1 argument
- sends that argument to dict://dict.org
- prints the formatted result.
- takes 1 argument.
- closes the current terminal then opens 2 new terminals to the directory specified by the argument.
- creates a tarball from the directory
- encrypts the tarball, deletes the tar ball and the original directory.
- Prints all environment variables to stdout
- By default the format is VARIABLE=VALUE\n
- Note: VALUE can be empty
- NULL can be used to separate variables instead of newline with
-0
- Comma (,) can be used to separate VARIABLE and VALUE with
-c
(or use with csv)
- stands for execute from.
- it takes a path (relative or absolute) as the first parameter, and a command as the second.
- then the command is executed as if current working directory was the one given
as the first parameter.
- E.g.
execf ~/ ls
will list the contents of the home directory (yes, just likels ~/
would).
- E.g.
- renames extensions of the files in the current directory
- and any subdirectories in it
- from the one supplied as the 1st argument to the one supplied as the second
- do not include dots
- E.g.
extrename c cpp
will rename all files that match*.c
to*.cpp
- reads file
- from stdin or as an argument
- interprets it as binary data
- converts binary data to some number format
- float by default
- use
floatdump -h
for details
- will rerun a command forever
- takes one or more files
- prints their sizes in bytes
- see
fsize -h
for more options
- takes the name of a license, one of:
- AGPL-3.0
- Apache-2.0
- BSD-2-Clause
- BSD-3-Clause
- BSL-1.0
- CC0-1.0
- EPL-2.0
- GPL-2.0
- GPL-3.0
- LGPL-2.1
- MIT
- MPL-2.0
- Unlicense
- copies said license to the LICENSE file in the current directory
- if a license requires copyright year to be specified (e.g. MIT), it will be
fetched with the unix
date
command - if a license requires author's name, it will first be taken from git's
user.name or, if that fails, from
$USER
- lists regular files in the current directry (not recursively) with their filetypes as deduced from the shebang.
- 0 if shebang is not supplied.
- takes a path and creates an empty file at that location
- creates all intermediate directories if they don't exist
- takes a path and an optional list of options (same ones as
objdump
) - uses
bat
to display the disassembled file.- defaults to intel syntax
- defaults to only
.text
data.
- takes tty number as the first argument and a command as the second.
- displays the output from the command to the specified tty.
- tty number can be found by running
tty
.
- Takes in a name of a pdf document
- Outputs number of words in the pdf
- Use
-s
to output just the number
- remove extension duplicates.
- finds files with the same name, but different extension
- removes all files with the unwanted extension.
- takes 2 arguments with an optional
-t|--test
flag.- first argument is the extension to keep (without the dot)
- the second one is extension to remove.
- -t or --test will not remove any files, instead it will print all of the rm commands it would have ran if -t was not supplied.
- -t can be used 1st or last, but not between the other 2 parameters.
- takes name of a file
- analogous to rmdir in that it will only delete empty files
- closes the current terminal and launches a program that was supplied as the argument.
- program has to be in
PATH
- works like it does on ubuntu.
- run (as root) after tweaking /etc/default/grub.
- same as
wcat
but using bat
- print the contents of files on path that were passed as arguments
- lifted from the suckless dwm documentation, rules section.
- Requires xprop and prints the basic information about the next window you click on in a human readable format.
- This information is often required by stand-alone window managers (and even some desktop environments).
git clone https://github.com/dk949/shellutils/
cd shellutils
make install
Note: This is the default method and it assumes that $HOME/.local/bin exists (it
will be created if not) and is on PATH. If you wish to install to a different
directory change DESTDIR
and/or PREFIX
variables in config.mk.