HP-UX/Bash: Getting comfortable in your shell


Introduction: I’m talking about the weird things after opening a shell on stud4

stud4 has a ugly configuration. If you connect, you get a minimal shell. the locale is set wrong, so you see the following all the time:

 Warning! One or more of your selected locales are not available.
Please invoke the commands "locale" and "locale -a" to verify your
selections and the available locales.
Continuing processing using the "C" locale.

Also, vi is no fun, and vim doesn’t accept the extended keyboard (delete, end).

Here I want to provide some info how you can improve your comfort.

1: start bash. Way better than the default shell.

bash

2: set your locale (language and localization). This is also in which language the error messages for example are.

export LC_ALL="en_US.utf8"
#export LC_ALL="de_DE.utf8"

For example:

[e0123456@stud4:~]$ export LC_ALL="en_US.utf8"
[e0123456@stud4:~]$ man
Usage: man [-M path] [-T macro-package] [ section ] name ...
or: man -k keyword ...
or: man -f file ...
[e0123456@stud4:~]$ export LC_ALL="de_DE.utf8"
[e0123456@stud4:~]$ man
Syntax: man [-M Pfad] [-T Makro-Paket] [ Sektion ] Befehlsname ...
oder: man -k Schlüsselwort ...
oder: man -f Datei ...
[e0123456@stud4:~]$

3: allow backspace

stty erase "^?"

4: get a informative prompt (second is with color)

PS1="[\u@\h \W]\\$ "
PS1="\e[0;34m[${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}]$ \e[m"

Example:

bash-2.04$ PS1="\e[0;34m[${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}]$ \e[m"
[e0123456@stud4:~]$

List of colors and manual

If you want that in your startup, write the following into your .bashrc

#!/bin/bash
export LC_ALL="en_US.utf8"
#export LC_ALL="de_DE.utf8"
stty erase "^?"
PS1="\e[0;34m[${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}]$ \e[m"

Now you may wonder, how can I write that easily in the freaking file?

pico .bashrc

To set pico, vim, xemacs or whatever your default editor (so "crontab -e" and other commands call it), use:

export EDITOR=pico

Another funny thing is XForwarding. Try this:

ssh e0123456@stud4.tuwien.ac.at -X
bash
xemacs

Ta-daa! A fat graphical editor. Of course only if you use X.
Also funny commands you can play with: xload, xbiff++, xclock, etc.

Really useful on the stud4 server is the script quotax:

[e0123456@stud4:~]$ quotax
Disk space limits on stud4:
---------------------------
Total disk space in home directory:   200 MB
Minimal free space for mail delivery:  10 MB
Maximal capacity of inbox folder:      50 MB
Disk usage summary for user e0123456:
-------------------------------------
Used disk space in home directory:  186.0 MB [93.0 %]
Free disk space in home directory:   13.9 MB [ 7.0 %]
Number of messages in inbox folder:  213
Size of inbox folder:                 2.0 MB [ 4.0 %]
Free space for incoming messages:     3.9 MB
WARNING: Remaining disk space in home directory is very low.
-------> There is not much space left for files and incoming mails.

At the end, some useful bash and vim tips for these crippled terminals:

bash:
Ctrl-A: begin of line
Ctrl-E: end of line
Ctrl-W: delete last word
vim: (watch out if you are in edit or command mode)
:dl      Delete letter
:dw    Delete word
:dd     Delete line
:wq    Write & quit
:q!      Quit without writing or anything

It is always worthy reading the according manuals (probably not on HP-UX, but on a linux machine or man-pages on the internet).

That’s it. Try things, don’t break things, and have fun.

  1. #1 by arved on June 24th, 2007

    The default shell on stud3 is not a “minimal shell”. If you want a minimal shell use /bin/sh. tcsh has a lot of features and is quite useful for interactive work, but of course the average Linux user only knows bash.

    I don’t know what you did wrong with yout locale settings. I don’t get this warning (most likely because i have not set a Locale variable) and my backspaces work fine, (maybe you set the wrong terminal type).

(will not be published)

  1. No trackbacks yet.