Skip to content

Instantly share code, notes, and snippets.

@schallis
Created December 30, 2010 10:29

Revisions

  1. schallis revised this gist Aug 14, 2011. 1 changed file with 15 additions and 3 deletions.
    18 changes: 15 additions & 3 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -3,16 +3,28 @@
    # $ tel steve
    # 3900 - Steve Challis

    # Terminal colour codes
    export CYAN="\033[0;36m"
    export GREEN="\033[0;32m"

    PHONE_LIST='/usr/share/phone-extensions.txt'

    tel() {
    local NUMBER=$CYAN
    local TEXT=$GREEN
    if [ ! $1 ]
    then
    # Show all if no argument specified
    # Show all if no argument specified
    cat $PHONE_LIST | less
    else
    # Use agrep if available
    type -p agrep &>/dev/null && grepper="agrep -1" || grepper="grep"
    echo "$grepper -i $* $PHONE_LIST | egrep '^[^\*].*'" | bash -;
    type -p agrep &>/dev/null && grepper="agrep -1" || grepper="grep"
    echo -en "$TEXT"
    echo -e "$grepper -i $* $PHONE_LIST |
    egrep '^[^\*].*' |
    sed 's/\([0-9]\{2,11\}x\{0,4\}\)/$NUMBER\1$TEXT/g'" |
    bash -
    echo -en "$NO_COLOUR"
    fi
    }

  2. schallis revised this gist Aug 14, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,6 @@ tel() {
    else
    # Use agrep if available
    type -p agrep &>/dev/null && grepper="agrep -1" || grepper="grep"
    echo "$grepper -i $* $PHONE_LIST | egrep "^[^\*].*"" | bash -;
    echo "$grepper -i $* $PHONE_LIST | egrep '^[^\*].*'" | bash -;
    fi
    }
  3. schallis revised this gist Aug 14, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,6 @@ tel() {
    else
    # Use agrep if available
    type -p agrep &>/dev/null && grepper="agrep -1" || grepper="grep"
    echo "$grepper -i $* $PHONE_LIST" | bash -;
    echo "$grepper -i $* $PHONE_LIST | egrep "^[^\*].*"" | bash -;
    fi
    }
  4. schallis revised this gist Aug 14, 2011. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -3,15 +3,16 @@
    # $ tel steve
    # 3900 - Steve Challis

    PHONE_LIST='/usr/share/phone-extensions.txt'

    tel() {
    list=~/usr/share/phone-extensions.txt
    if [ ! $1 ]
    then
    # Show all if no argument specified
    cat $list | less
    cat $PHONE_LIST | less
    else
    # Use agrep if available
    type -p agrep &>/dev/null && grepper="agrep -1" || grepper="grep"
    echo "$grepper -i $* $list" | bash -;
    echo "$grepper -i $* $PHONE_LIST" | bash -;
    fi
    }
  5. schallis revised this gist Aug 14, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Quick Bash function lookup for telephone extensions
    # Quick Bash function to lookup telephone extensions. Better if agrep is installed.
    # Usage:
    # $ tel steve
    # 3900 - Steve Challis
  6. schallis renamed this gist Aug 14, 2011. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. schallis revised this gist Aug 14, 2011. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions Telephone list lookup
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,7 @@
    # Quick Bash function lookup for telephone extensions
    # Usage:
    # $ tel steve
    # 3900 - Steve Challis

    tel() {
    list=~/usr/share/phone-extensions.txt
  8. schallis created this gist Dec 30, 2010.
    14 changes: 14 additions & 0 deletions Telephone list lookup
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    # Quick Bash function lookup for telephone extensions

    tel() {
    list=~/usr/share/phone-extensions.txt
    if [ ! $1 ]
    then
    # Show all if no argument specified
    cat $list | less
    else
    # Use agrep if available
    type -p agrep &>/dev/null && grepper="agrep -1" || grepper="grep"
    echo "$grepper -i $* $list" | bash -;
    fi
    }