From: martin f. krafft Date: Fri, 9 May 2008 18:42:26 +0000 (+0100) Subject: functions to convert number bases X-Git-Url: https://git.madduck.net/etc/zsh.git/commitdiff_plain/84eace384293216f79aaff7df442afb9414cbf57?ds=sidebyside;pf=etc functions to convert number bases --- diff --git a/.zsh/func/baseconv b/.zsh/func/baseconv new file mode 100755 index 0000000..b42f5fa --- /dev/null +++ b/.zsh/func/baseconv @@ -0,0 +1,10 @@ +#!/bin/sh + +if [ $# -ne 3 ]; then + echo Usage: ${0##*/} ibase obase number + return 1 +fi + +typeset -li $2 var +eval ((var=${1}#${3})) +echo ${var#*\#} diff --git a/.zsh/zshrc/30_aliases b/.zsh/zshrc/30_aliases index a511722..bc0f27a 100644 --- a/.zsh/zshrc/30_aliases +++ b/.zsh/zshrc/30_aliases @@ -76,6 +76,14 @@ alias mps='ps -ao user,pcpu,start,command' alias bofh='fortune bofh-excuses' +autoload -U baseconv +alias b2d='baseconv 2 10' +alias d2b='baseconv 10 2' +alias d2h='baseconv 10 16' +alias h2d='baseconv 16 10' +alias d2o='baseconv 10 8' +alias o2d='baseconv 8 10' + _d() { dict $* } d() { _d $* | sensible-pager } the() { d -d moby-thesaurus $* }