alias decolor="perl -pe 's/\x1b\[[0-9;]*m//g'"
alias ls="ls --color=auto"
alias restart="/etc/init.d/biosmart restart"
alias tac="perl -e 'print reverse <>'"
alias llog="tail -f /var/log/biosmart"
alias tt="tail -fn1000 /var/log/biosmart"
alias tlog="cat /var/log/biosmart | decolor | less"
alias vic="vi /etc/prosoft-biometrics/BIOSMART\ PV\ WTC\ 2.conf"
alias tl="cat /var/log/biosmart | tail"

function last-fw {
  ls -lart  | sed -rne 's/.*(BIOSMART.*)/\1/p' | tail -1
}
export -f last-fw

function replace-fw {
  declare TARGET="$*"
  : ${TARGET:=`last-fw`}
  tar -xf "$TARGET" -C /home/root/biosmart
  sync
  rm /home/root/biosmart.db
  /etc/init.d/biosmart restart
}
export -f replace-fw

function prepare-fw {
  cd
  rm -rf fw
  rm fw.tar.gz
  mkdir fw
  declare TARGET="$*"
  : ${TARGET:=`last-fw`}
  tar -xf "$TARGET" -C fw
  cp "$TARGET" fw.tar.gz
  cd fw
}
export -f prepare-fw

function install-fw {
  prepare-fw "$*"
  /etc/init.d/biosmart stop
  chmod +x ./install.sh
  ./install.sh --nofw
  /etc/init.d/biosmart start
  cd -
}
export -f install-fw

# bind "\e[1;5C": forward-word
# bind "\e[1;5D": backward-word

