]> id.pley.net Git - dotfiles.git/blobdiff - zsh_aliases
Update zsh aliases and settings
[dotfiles.git] / zsh_aliases
index dae48a80b8282e58f37070204365030486cc4720..05e1a1054364154bdaf3917e109357fe1efcb473 100644 (file)
@@ -22,6 +22,7 @@ alias p='ps -au'
 alias tf='tail -25f'
 alias l='ls -lF'
 alias la='ls -laF'
+alias less='less -R'
 alias clr='clear'
 alias cls='clear'
 alias d='date'
@@ -51,16 +52,39 @@ function viw () { vi $(which $1); }
 function toss () { mv -f $@ ~/.trashcan; }
 function xcopy () { tar cvf - -C $1 $1/* | tar xvf - -C $2; }
 function checkdns () { ping $( grep nameserver /etc/resolv.conf | awk '{print $2}' | head -1); }
+function has () { 
+    which $1 &> /dev/null
+    if [[ $? -eq 0 ]]; then
+        echo 'yes'
+        return 0
+    else
+        echo 'no'
+        return 1
+    fi
+}
 
-if [[ $(which pidof &> /dev/null; echo $?) -eq 1 ]]; then
+if [[ $( has pidof ) == 'no'  ]]; then
     function pidof () { ps -e -o pid,comm | grep "$1" | awk '{print $1}'; }
 fi
 
 function ssh-forget() {
-    sed -i "" "/^$1,/d" ~/.ssh/known_hosts
+    sed -i "" "/^$1[, ]/d" ~/.ssh/known_hosts
 }
 
 function ssh-learn() {
-    sed -i "" "/^$1,/d" ~/.ssh/known_hosts
+    sed -i "" "/^$1[, ]/d" ~/.ssh/known_hosts
     ssh-keyscan -t rsa $1 >> ~/.ssh/known_hosts
 }
+
+function canonicalize() {
+    local relpath=$( dirname $1 )
+    if [[ ! -d "$relpath" ]]; then
+        echo "$0: no such file or directory: $1"
+        return 1
+    fi
+
+    echo $(cd $relpath; pwd -P)/$(basename $1)
+    return 0
+}
+
+function sayStatus () { local _status=$?; if [[ $_status -eq 0 ]]; then say "Success"; else say "Failed"; fi; return $_status }