From Electron Cloud
Revision as of 15:24, 22 June 2009 by Ecloud (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Shell aliases

alias cdp='cd project-dir'
alias cdb='cd project-binary-dir'
alias cdl='cd /var/log'
alias iw='watch "iwconfig wlan0; ifconfig wlan0; ps aux | grep dhcp | grep -v grep"'
alias ko='killall -9 "binary1" "binary2" etc'
alias l='ls -F'
alias ll='ls -la'
alias lt='ls -ltr'
alias pow='cat /proc/acpi/battery/BAT1/info | grep last | cat - /proc/acpi/battery/BAT1/state /proc/acpi/thermal_zone/THRM/temperature'
alias rxvt='rxvt -sr -bg black -fg white -geometry 80x60 -sl 10000'

Color bash prompt with time and cwd

Bash prompt (yellow for "foreign" systems):

# prompt
case $TERM in
    xterm*)
        TITLEBAR='\[\033]0;\u@\h:\w\007\]'
        ;;
    *)
        TITLEBAR=''
        ;;
esac

        BLUE="\[\033[0;34m\]"
  LIGHT_GRAY="\[\033[0;37m\]"
 LIGHT_GREEN="\[\033[1;32m\]"
  LIGHT_BLUE="\[\033[1;34m\]"
  LIGHT_CYAN="\[\033[1;36m\]"
      YELLOW="\[\033[1;33m\]"
       WHITE="\[\033[1;37m\]"
         RED="\[\033[0;31m\]"
    NO_COLOR="\[\033[0m\]"

PS1="${TITLEBAR}\n\
$LIGHT_CYAN\w$NO_COLOR\n\
[$RED\h$NO_COLOR][$YELLOW\$(date +%r)$NO_COLOR] \
"
PS2='> '
PS4='+ '

Type "pow" to see power and sensor status

This is my personal convention on machines I use regularly. The aliases above include one version of this; see also other ways to implement it.

Console clock

Below is a script for an upper-right console clock. It can be called bgclock but I don't know the best way to make it put itself into the background. Could use raw ANSI codes rather than tput, but I'm lazy.

#!/bin/sh
while [ 1 ]
do
        COLS=$((`tput cols` - 8))
        tput sc; tput cup 0 $COLS; date +%H:%M:%S; tput rc
        sleep 1
done