Random Functions for ksh

# Prints the username@hostname in the title of an xterm

echo “\033]0;${USER}@${HOSTNAME}\007”

# A ksh function similar to perl’s chomp function. Thanks to an OS Plumber

chomp() {
# Usage: $1 is string to chomp, $2 is char to chomp off := defaults to \n
char=${2:=$’\n’}
echo “${1%$char}”
}

center() {
c_width=$(tput cols)
c_text=”$*”
c_width=$(( ($c_width + ${#c_text}) / 2 ))
printf “%${c_width}.${c_width}s\n” “$c_text”
}

h2d() {
printf “%d\n” $@
}

1 thought on “Random Functions for ksh

Comments are closed.

Soapbox Artist: collecting art & literature of the worst kind