This is a collection of various unrelated bash
and perl
scripts.
The scripts had initially been written for Arch Linux. Some may not work out of the box on every machine as some files could reside at different locations or some software may not be present on the system, at all. A lot of scripts are wrappers around other Linux command line tools, some are almost one-liners and only few are a little bit more sophisticated somehow.
All scripts are licensed under the GNU General Public License, version 3.
The source code of the scripts can be used as example to write tools working for specific platforms and/or configurations.
First, this repository needs to be cloned to a local directory. Then, scripts being used may be made executable.
In order to install scripts, they may be placed (or linked) under /usr/bin
,
or /usr/local/bin
, with their filename extension stripped.
For example, to use the tool battery.pl
, it can be installed by running:
git clone https://github.com/mcrbt/local-bin.git
chmod 755 battery.pl
cp $(pwd)/local-bin/battery.pl /usr/local/bin/battery
To get the battery status, battery.pl
can then simply be run as:
battery
Alternatively, a symbolic link to the script may be created, which would do the same trick:
ln -sv $(pwd)/local-bin/battery.pl /usr/local/bin/battery
The collection currently contains the following 27 scripts:
-
- print hardware address (i.e. MAC address) of the wireless access point currently connected to
-
- print capacity (percentage) of one or two installed batteries, along with their charging status
- if more than one battery is installed, a cumulated capacity is calculated
- the path of the battery system files may be changed accordingly
-
- copy e.g. configuration files of user
root
to all other user's home directories - configuration directories (e.g.
.config/openbox/
) can be copied recursively - intended for single user systems with an additional non-privileged user, e.g. to execute riskier tasks
- allows to only modify the configuration file of user
root
, and afterwards "synchronize" with all other user accounts having a home directory under/home/
- configuration is to be done within the script using the global constant
QUIET
to control verbosity, andSYNC_LIST
for a space (" ") separated list of filenames (with or without/root/
prefix) - alternatively, files (resp. directories) can be provided via command
line, each as its own argument (e.g.
$ cfgsync .bashrc .xinitrc
; see$ cfgsync --help
for details) - CAUTION: the script is intended to override existing configuration files of local users
- copy e.g. configuration files of user
-
- clear
bash
command history of current user - must be "sourced" in the current terminal:
. clean.sh
- clear
-
- open
firefox
and search a pattern with DuckDuckGo search engine from command line
- open
-
- translate a pattern on https://www.dict.cc
- the pattern is supplied as command line arguments and can consist of multiple words (i.e. multiple arguments)
- the web browser may be configured, by altering the variable
BROWSER
(defaults tofirefox
)
-
- retrieve IP address for a specific host name and vice versa using
the
host
tool
- retrieve IP address for a specific host name and vice versa using
the
-
- strip documentation and comments from a
doxygen
Doxyfile - a default Doxyfile may be generated by
doxygen
using the command$ doxygen -g
, which contains lots of very useful documentation comments - unfortunately, that file is approximately 2500 lines (112 KiB)
doxystrip
removes comments from the Doxyfile, to let it only be about 330 lines (12 KiB)
- strip documentation and comments from a
-
- convert between plain ASCII strings, and its hexadecimal ASCII representation
-
- extract information about the default network interface and its assigned IP addresses
-
- "incorporate" foreign files into a Linux file system by adapting their names
- whitespaces and lots of special characters are replaced with underscore ("_"), German umlauts and other graphemes are converted to their ASCII representation (e.g. "ä"->"ae", "â"->"a", ...)
-
- start any program as background task from command line, with definitely no output
- any arguments are forwarded to the new process
- most useful for software with graphical user interface, to detach the background task from the current shell
-
- print active network interface, private IP address (LAN), public IP address (WAN), and Tor exit relay IP address, if any
- depends on
systemd
init system
-
- view manual pages online, at https://www.man7.org
-
- generate fresh pacman mirrorlist with reflector
- wrapper around
reflector
- intended for Arch Linux systems or derivatives with
pacman
package manager
-
- list "relevant" devices (hard drives, USB storage devices, SD cards), currently mounted
-
- search for C preprocessor macros or special function register declarations in the specified (or default) MSP430 header file
- assumes the Texas Instruments®
mspgcc
toolchain - default MSP430 include path, as well as default target device (e.g.
msp430f5529
) can be configured - prints whatever the
grep
command returns, or "nothing found" - example usage:
$ msp430macro msp430f5529 UCB0TXBUF
-
- delete cached and orphaned packages
- intended for Arch Linux systems or derivatives with
pacman
package manager
-
- query a key server for PGP public keys
-
- list network printers and their IP address
- wrapper around
lpstat
-
- generate password(s) of configurable length(s)
- wrapper around
pwgen
from Theodore Ts'o <tytso@alum.mit.edu>
-
- reopen hyperlinks stored in separate "
.href
" or ".url
" files, or a single file containing one hyperlink per line
- reopen hyperlinks stored in separate "
-
- remove the last screenshot, accidently taken
- needs to be adapted in order to work with screenshot taking application (regards file naming conventions, and storage location)
-
- list available storage space of relevant devices
- wrapper around
df
-
- open a new Tor circuit by restarting the
tor
service - it is supposed, that the
tor
daemon is already running - when done, the old, as well as the new exit node IP address is printed
- depends on Arch Linux's init system,
systemd
, for managingtor
service
- open a new Tor circuit by restarting the
-
- disables/ re-enables the trackpad device (and the TrackPoint®
device of Lenovo® ThinkPad® laptops, if available)
- if no parameter is given, the trackpad is disabled if an optical USB mouse is detected, and enabled if there is no such mouse
- disables/ re-enables the trackpad device (and the TrackPoint®
device of Lenovo® ThinkPad® laptops, if available)
-
- open a specific Wikipedia article from the command line
- support for any language Wikipedia is available in
Copyright © 2018-2023 Daniel Haase
All scripts of local-bin
are licensed under the
GNU General Public License, version 3.
local-bin - collection of various command line scripts
Copyright (C) 2018-2023 Daniel Haase
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see
<https://www.gnu.org/licenses/gpl-3.0.txt>.