Chapter 8: BS-NG Functions
1 Admin functions
A set of more or less administrative functions
1.1 torswitch
Torswitch is a simple function for switching on or off
the Tor Union-Router globally, when using Privoxy.
torswitch --on #turn on tor
torswitch --off #turn of tor
1.2 repoadd
RepoAdd is a script for adding debian-packages to an already
set-up apt-repo which uses reprepro to be organized
The paths it uses are set by environment-variables
REPO_HOME the root-directory of the apt-repo
REPO_DIST the dist you wan to add your packages to
signing is done automatically
1.3 wipe
Wipe overwrites the given device with random numbers
Use this on an empty partition which you want to crypt-setup later
DON'T USE THIS ON PARTITIONS WHICH CONTAIN FILES YOU WANT TO KEEP!
wipe <device>
1.4 remount
Simply remount a device with given options
remount <device> <options>
1.5 treeps
&nbps;A wrapper around ps with nicer output
2 Conversion functions
Various functions for conversion
2.1 dos2unix
d2u: for converting dos-lineendings to unix-lineendings
u2d: for converting unix-lineendings to dos-lineendings
2.2 binary conversion
bin2oct: convert binary to octal number
bin2dec: convert binary to decimal number
bin2hex: convert binary to hexadecimal number
bin2b32: convert binary to base 32
bin2b64: convert binary to base 64
bin2asc: convert binary to ascii
bin2all: overview of all above
2.3 octal conversion
oct2bin: convert octal to binary number
oct2dec: convert octal to decimal number
oct2hex: convert octal to hexadecimal number
oct2b32: convert octal to base 32
oct2b64: convert octal to base 64
oct2asc: convert octal to ascii
oct2all: overview of all above
2.4 decimal conversion
dec2oct: convert decimal to octal number
dec2bin: convert decimal to binary number
dec2hex: convert decimal to hexadecimal number
dec2b32: convert decimal to base 32
dec2b64: convert decimal to base 64
dec2asc: convert decimal to ascii
dec2all: overview of all above
2.5 hexadecimal conversion
hex2oct: convert hexadecimal to octal number
hex2dec: convert hexadecimal to decimal number
hex2bin: convert hexadecimal to binary number
hex2b32: convert hexadecimal to base 32
hex2b64: convert hexadecimal to base 64
hex2asc: convert hexadecimal to ascii
hex2all: overview of all above
2.6 ascii conversion
asc2oct: convert ascii to octal number
asc2dec: convert ascii to decimal number
asc2bin: convert ascii to binary number
asc2hex: convert ascii to ascii number
asc2b32: convert ascii to base 32
asc2b64: convert ascii to base 64
asc2all: overview of all above
2.7 degree conversion
cel2fah: convert °C to °F
cel2kel: convert °C to °K
fah2cel: convert °F to °C
fah2kel: convert °F to °K
kel2cel: convert °K to °C
kel2fah: convert °K to °F
2.a misc conversion
arabic2roman: convert arabic numbers (0...9) to roman (I...M)
text2morse: convert plain-text into morse-code
morse2text: convert morse-code into plain-text
2b algebra functions
Small set of algebra functions
2b.1 round
Round a decimal (use `,' as delimiter)
round 2,457863 2 # = 2,46
2b.2 radical
Calculate the square-root of a decimal (use `.' as delimiter)
2b.3 power
Calculate the nth power of a number
radical 2 16 # = 2^16 = 65536
3 Info functions
3.1 count_files
Function for counting files in the current directory, see --help
3.2 count_processes
Function for counting processes
3.3 show_battery_load
Function for displaying the battery load, via --acpi or --apm
3.4 show_cpu_load
Function for displaying the CPU-Load
3.5 show_ip
Function for displaying the ip-address of a given interface, see --help
3.6 show_mem
Function for displaying the current free/used ram in mb/percent, see --help
3.7 show_size
&nbps;Function for displaying the size of all files in the current directory
3.8 show_space
Function for displaying the free space of a given device, see --help
3.9 show_system_load
Function for displaying the system-load, see --help
3.10 show_tty
Function for displaying the current TTY (in a stylish manner)
3.11 show_uptime
Function for displaying the machine's uptime
3.12 system_infos
Function for getting various system informations, see system_infos --help
3.13 show_weather
Function for displaying current weather
show_weather Nürnberg
uses city from USER_LOCATION if set
4 Media functions
4.1 geniso
Function for creating an ISO9660 image from a cd/dvd-drive
uses DD_OPTS and CD_WRITER variables
4.2 writeiso
Simple function for writing an ISO9660 image to a disc
uses cdrecord and CD_WRITER variable
4.3 youtube2ogg
Extracts the audio of .flv files to an OGG/Vorbis file (uses ffmpeg)
4.4 conv2avi
Simple function for converting a mencoder-supported video file to
AVI (XVid/Lame), uses mencoder-mt if available
5 Misc. functions
5.1 top10
Function for displaying your ten most-used commands
5.2 crypt
Function for "en/decrypting" text-files using ROT13 method
5.3 get_kernel
Function for grabbing kernel-sources, supports various options
-s VERSION for stable, -t VERSION for testing, -sg VERSION for
stable GIT, -tg VERSION for testing GIT, -z VERSION REVISION
for getting Zen kernel-patches
5.4 stop_watch
Simple stopwatch for bash (Ctrl-C to stop)
5.5 bashtips
Displays some useful tips about Bash
5.6 define
Get the definition of a word
5.7 kitt
Toy for the linux-console that flashes the keyboard leds
just like K.I.T.T's from Knight Rider.
5a ls variants
Some variants of the ls-command
5a.1 ll
Display ls-output as list, directories first
5a.2 la
Normal ls, but hidden files included
5a.3 l1
Normal ls, but one file per line (usefull for scripts)
5a.4 lo
Display a list of files and their owner
5a.5 lg
Display a list of files and their group
5a.6 lm
Display the permissions of given files (human-readable and octal)
6 Random functions
6.1 random
Function for generating random numbers, use -l LENGTH
to set the length of the number, -r RANGE to set the
range of the number (so it will be between 0 and RANGE)
6.2 randompw
Function similar to random, but outputting strings
which may be used for passwords, eg randompw 16
generates a 16 chars long password containing letters
and numbers randompw 16 ! (note the !) additionally
add special charachters to the output
6.3 randomfile
Randomly select a file and output, see randomfile --help
7 Utility functions
7.1 bookmark
Create a bookmark for the current directory, eg bookmark example
will add a go-example command which will then go back to that directory
7.2 unmark
Remove a bookmark, eg unmark example will remove go-example
7.3 up
Easier way of going up several directories, eg instead of
cd ../../../../../ you do up 5
7.4 deadlink
Search current directory for dead links
7.5 empty
Search current directory for empty files
7.6 exchange
Exchange the value of two variables, eg exchange $X $Y
before: X=2 Y=4, afterwards X=4 Y=2
7.7 man2pdf
Create a PDF from a manual page
7.8 trunc_pwd
Used by the styles, to provide nicer pwd-output than \w and \W
7.9 xdel
Deletes all files recursively matching the pattern without asking!
This is only loaded on Bash 4.0+
7.10 xalias
Wrapper for alias, which stores the alias in your $HOME/.custom-rc
so that it is available in other sessions, too
7.11 xunalias
Counterpart to xalias
7.12 up
cd given levels up (up 4 = cd ../../../../)
7.13 swap
Exchange two files
7.14 progressbar
Displays a fancy progressbar, examples:
first do: sleep 15 & => then one of the following:
progressbar $!
progressbar $! oOOOo
progressbar $! "+ = "
instead of $! you might give it the PID of a process to watch
(also valid for all other bars/spinners now following)
7.15 spinner
Displays a spinner, example:
sleep 10 &
spinner $!
7.16 spanner
Alternative spinner, which moves the cursor around, instad of rotating
sleep 10&
spanner $!
7.17 working
Displays animated "working" text
sleep 15 &
working $!
7.18 spin
Combination of spinner and spanner
sleep 10 &
spin $!
7.19 clock
A simple clock for the terminal (Ctrl-C to exit)
7.20 treefind
Replacement for find, with nicer output
7.21 wininfo
Get useful info about a window (WM_NAME etc.)
(for more infos, directly use xprop)
7.22 repeat
repeat a command at a given intervall
repeat 3 echo "hello world"
7.23 hilow
Small game for BASH
7.24 colorshell
Changes the color of the text after each command (loaded internally)
7.25 nseq
Print out all numbers from 1 to a given one
7.26 ruler
The ruler™ for your terminal.
7.27 box
Decorate text with a nice box. Last arg is used as character for the box
7.28 binary-clock
Binary clock for the terminal (Ctrl-C to exit)
7.29 ugrep
Look-up Unicode characters
8 Versioning functions
8.1 git_export
GIT version of svn export (export tree ready-to-use for release)
8.2 git_bzip
Create .tar.bz2 archive from the tree, ready-to-use for release
8.3 git_xz
Same as git_bzip but using XZ for compression
8.4 get_gnome
&nbps;Function for grabbing git.gnome.org repos
&nbps;uses GIT_GNOME_USER variable if you have an account
examples for maintainers: get_gnome -m nautilus
get_gnome -mb nautilus 2-30 (checkout branch 2-30)
examples for users: get_gnome nautilus
get_gnome -b nautilus 2-30 (checkout branch 2-30)
8.5 get_xfce
Same as get_gnome but for git.xfce.org, uses GIT_XFCE_USER
8.6 git_branch
Display the current branch
8.7 git_revision
Displays the current revision as 6-digit-number
8.8 git_action
Display the currently running action (eg: merge)
8.9 get_kde
Same as get_gnome but for svn.kde.org (may not work for all)
uses SVN_USER_KDE variable
8.10 get_e
Same as get_gnome but for svn.enlightenment.org; -b and -mb
options are missing, though. Uses SVN_USER_ENLIGHTENMENT
9 Internal functions/variables
9.1 BSNG_PREFIX
Environment-variable containing the installation-prefix of BS-NG
9.2 BSNG_RC_DIR
Environment-variable containing the path to the functions directory
9.3 BSNG_LOCKFILE
Environment-variable containing the path to the loCKfile
9.4 BSNG_VERSION
Environment-variable containing the version of BS-NG
9.5 BSNG_LOGFILE
Environment-variable containing the path to the loGfile
9.6 BSNG_DOCS
Environment-variable containing the path to the documentation
9.7 dbg_msg
Displays the debug messages on startup and stores them
9.8 dbg_view
Displays the debug-log
9.9 dbg_verbosity
Function for enabling/disabling the verbose debugging at startup
9.10 check_opt
Check optional dependencies for scripts, on run-time
9.12 get_key
Get the value of a BashStyle-NG GConf-Key
9.13 set_key
Set the value of a BashStyle-NG GConf-Key
9.14 reset_key
Reset the value of a BashStyle-NG GConf-Key
9.15 reset_config
Reset the BS-NG settings to defaults
9.16 search_key
Search for a GConf-Key
9.17 dbg_log
Creates a log entry
9.18 dbg_finalize
Finalizes the debug-log
9.19 dbg_verbosity
Enable/disable the debug-text on startup
dbg_verbosity true [or: false]
9.20 rc_add
Adds entries to various rc files (used for better readability)
9.21 BSNG_BIN_DIR
Location of BashStyle-NG binaries