## Chapter 8: BS-NG Functions

Chapter 7 << | Index | >> Chapter 9

### Until BashStyle-NG 7.7:

### BS-NG-Echo

This function will "parse" the Colorcodes, to make them usable with `echo'.

echo -e $usercolor hello | See - doesn't work correctly.
echo -e $(bs-ng-echo $usercolor) hello | See - this does work now.

### BS-NG-Profiler

This script will import or export your current configuration.

bs-ng-profiler | export |  | Export your profile into a plain-text file.
| import | a saved profile | Import an already saved profile.

### Countfiles

This function will show how many files/folders are in the current directory.

count_files | +h | Count files, folders (and hidden ones).
| -h | Count files, folders (no hidden ones).
| -d | Count folders (no hidden ones).
| +d | Count folders (and hidden ones).
| -f | Count files (no hidden ones).
| +f | Count files (and hidden ones).

### Count Processes

This function counts all running processes.

count_processes | no options.

### Show-Battery-Load

This function will show your lappy's battery load, using APM.

show_battery_load | acpi | use acpi for getting batteryload.
| apm | use apm for getting batteryload.

### Show-CPU-Load

This function will show your CPU load.

show_cpu_load | no options.

### Show-System-Load

This function will show your system load.

show_system_load | 1 | Load average for 1 minute.
| 10 | Load average for 10 minutes.
| 15 | Load average for 15 minutes.

### Show-Memory

This function will show your memory load.

show_mem | --used | Shows used memory in MB.
| --used-percent | Shows used memory in Percent.
| --free | Shows free memory in MB.
| --free-percent | Shows free memory in Percent.

### Show-Size

This function will show the size of all files in the current directory.

show_size | no options.

### Show-Space

This function will show your disk space.

show_space | --used | mountpoint | Shows the used space in MB/GB.
| --used-percent | mountpoint | Shows the used space in Percent.
| --free | mountpoint | Shows the free space in MB/GB.
| --free-percent | mountpoint | Shows the free space in Percent.
| --total | mountpoint | Shows the total space in MB/GB.

### Show-TTY

This function shows the current TTY (Terminal Device).

show_tty | no options.

### Show-Uptime

This function will show your system's uptime.

show_uptime | no options.

### TruncPWD

This function will print a modified version of $PWD.

trunc_pwd | no options.

### Show-IP

This function will show your external ip address.

show_ip | <interface> | show external ip address of <interface>.

### Man 2 PDF

This function will convert a manpage to a pdf file.

man2pdf <manpage> | convert <manpage> into a pdf.

### System-Infos

This function will show serveral system informations.

system_infos | --cpu | Display CPU Model and Frequency.
| --kernel | Display Kernel Release, Version and Machine.
| --memory | Display Total, Free and Used RAM.
| --partitions | Display Major, Minor, Blocks and Node for all recognized paritions.
| --pci | Display Infos about all PCI Devices (and their kernel-module).
| --usb | Display Infos about all USB Devices (and their kernel-module).
| --bios | Display SMBIOS/DMI Informations.
| --mounts | Display all mounted devices.

### RCGenerator

This script will generate standalone rc-files.

rcgenerator | --bash | Generate standalone bashrc.
| --readline | Generate standalone inputrc.
| --vim | Generate standalone vimrc.
| --nano | Generate standalone nanorc.
| --all | Generate standalone rcs for all four.

### New in BashStyle-NG 7.8:

### xchown

Recursive chown for given user, with root priviledges, via su.

xchown | USER | FILES/FOLDERS

### xmv

Move files to last arguement, if that directory does not exist, create it before moving.

xmv | FILE FILE FILE FILE DESTINATION

### xcp

Same than xmv, but for copying instead of moving.

xcp | FILE FILE FILE FILE DESTINATION

### xdel

Delete matching files recursively (also: `rm of doom').

xdel | pattern

### xconv

Xconv is a set of functions for converting numbers.

bin2oct | convert binary to octal.
bin2dec | convert binary to decimal.
bin2hex | convert binary to hexadecimal.
bin2all | convert binary to all three.
oct2bin | convert octal to binary.
oct2dec | convert octal to decimal.
oct2hex | convert octal to hexadecimal
oct2all | convert octal to all three.
dec2bin | convert decimal to binary.
dec2oct | convert decimal to octal.
dec2hex | convert decimal to hexadecimal.
dec2all | convert decimal to all three.
hex2bin | convert hexadecimal to binary.
hex2oct | convert hexadecimal to octal.
hex2dec | convert hexadecimal to decimal
hex2all | convert hexadecimal to all three.
round | round a decimal.
radical | get the square-root of a decimal.
power | get the n-th power of a decimal.

### xunalias

Xunalias is a replacement for unalias, which does not err if an alias
can't be unaliased (usefull for scripts).

xunalias | alias

### ls functions

A set of extra `ls' variants.

ll | show detailed infos.
la | also display hidden files.
l1 | display one file per line.
lo | display owner of file.
lg | display group of file.
lm | display mode of file.

### git functions

A set of extra `git' functions.

git_export | PATH | export the git-tree to PATH.
git_bzip |  | create bzip2-compressed tarball from the git-tree.
git_xz |  | create xz-compressed tarball from the git-tree.

### exchange

Exchange the value of two variables.

exchange | VARIABLE1 | VARIABLE2

### New in BashStyle-NG 7.9:

### random

Print a random number.

random | -l LENGTH | Print a random number with length LENGTH
| -r RANGE | Print a random number between 0 and RANGE

### New in BashStyle-NG 7.9.1:

### ps

A set of `ps' related functions

psgrep | -u | USER | Print all processes belonging to USER
|  | PROCESSNAME | Print all running processes matching PROCESSNAME

pskill | PROCESSNAME |  | psgrep for PROCESSNAME and ask for a process to kill
pskill | PROCESSNAME | SIGNAL | psgrep for PROCESSNAME and ask for a process to kill via signal SIGNAL

### New in BashStyle-NG 7.10:

### top10

Display the 10 most-used commands

top10

### randompw

Create a random password

randompw | LENGTH | ! | generate alphanumeric password with length LENGTH if ! is passed, too, then include special chars

### dbg_view

View the debug log

dbg_view

### dbg_verbosity

Set the debug verbosity

dbg_verbosity | 0 | No output on bash startup
| 1 | Full output on bash startup

### crypt

"encrypt" a plaintext file. Actually the characters
are simply exchanged, which makes the content unreadable
run a second time to "decrypt" the file

crypt | FILE | "encrypt" or "decrypt" FILE

### dos2unix

Change line-endings from dos to unix and vice versa

d2u | FILE | Convert FILEs line-endings from dos to unix
u2d | FILE | Convert FILEs line-endings from unix to dos

git functions A set of extra `git' functions.

get_gnome | -m | USERNAME | PROJECT | checkout head of PROJECT as user USERNAME from git.gnome.org
| -b | BRANCH | PROJECT | checkout branch BRANCH of PROJECT as anonymous from git.gnome.org
|  |  | PROJECT | checkout head of PROJECT as anonymous from git.gnome.org

get_xfce | -b | BRANCH | PROJECT | checkout branch BRANCH of PROJECT as anonymous from git.gnome.org
|  |  | PROJECT | checkout head of PROJECT as anonymous from git.gnome.org

git_xz | create xz-compressed tarball from the git-tree.

### Internal functions/variables (may also be used externally):

### BSNG_PREFIX

Environment-variable containing the installation-prefix of BS-NG

### BSNG_RC_DIR

Environment-variable containing the path to the functions directory

### BSNG_LOCKFILE

Environment-variable containing the path to the loCKfile

### BSNG_VERSION

Environment-variable containing the version of BS-NG

### BSNG_LOGFILE

Environment-variable containing the path to the loGfile

### bsource

Load BS-NG functions by name of the file instead of absolute path

### dbg_msg

Displays the debug messages on startup and stores them

### check_opt

Check optional dependencies for scripts

### BSNG_GCONF_READ

Environment-variable used by get_key/set_key

### get_key

Get the value of a GConf-Key (listens to BSNG_GCONF_READ)

### set_key

Set the value of a GConf-Key (listens to BSNG_GCONF_READ)

### reset_key

Reset the value of a GConf-Key (listens to BSNG_GCONF_READ)

### reset_config

Reset the BS-NG settings

### search_key

Search for a GConf-Key