]> id.pley.net Git - dotfiles.git/commitdiff
Add canonicalize() function.
authorJer Noble <jer.noble@apple.com>
Wed, 25 Sep 2013 23:11:39 +0000 (16:11 -0700)
committerJer Noble <jer.noble@apple.com>
Wed, 25 Sep 2013 23:15:28 +0000 (16:15 -0700)
zsh_aliases

index f3307028ed3a578bb76c49721eca2be786108916..1728fa30dc36d3856a8acf9fae7633aa624b4a1b 100644 (file)
@@ -74,3 +74,14 @@ function ssh-learn() {
     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
+}