From 84eace384293216f79aaff7df442afb9414cbf57 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Fri, 9 May 2008 19:42:26 +0100 Subject: [PATCH] functions to convert number bases --- .zsh/func/baseconv | 10 ++++++++++ .zsh/zshrc/30_aliases | 8 ++++++++ 2 files changed, 18 insertions(+) create mode 100755 .zsh/func/baseconv 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 $* } -- 2.39.5