From f45b43a267c45bab9aa00c95ad7fa34cf3c1810d Mon Sep 17 00:00:00 2001 From: Pat Regan Date: Sun, 15 May 2011 17:05:11 -0400 Subject: [PATCH 1/2] Add a "go" command plugin --- plugins/go-command/go-command.plugin.zsh | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 plugins/go-command/go-command.plugin.zsh diff --git a/plugins/go-command/go-command.plugin.zsh b/plugins/go-command/go-command.plugin.zsh new file mode 100644 index 000000000..383a05356 --- /dev/null +++ b/plugins/go-command/go-command.plugin.zsh @@ -0,0 +1,27 @@ +go() { + if [ -f "$1" ]; then + if [ -n "`file $1 | grep '\(text\|empty\|no magic\)'`" ]; then + $EDITOR "$1" + else + if [ -e "`which xdg-open`" ]; then + if [ -n "$DISPLAY" ]; then + xdg-open "$1" > /dev/null + else + echo "DISPLAY not set: xdg-open requires X11" + fi + else + echo "xdg-open not found: unable to open '$1'" + fi + fi + elif [ -d "$1" ]; then + cd "$1" + elif [ "" = "$1" ]; then + cd + elif [ -n "`declare -f | grep '^j ()'`" ]; then + j "$1" + else + echo "Ran out of things to do with '$1'" + fi +} + +alias g=go From 6148480e69b41ce4842e87293fb3956c73fa61be Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 18 May 2011 05:35:02 -0400 Subject: [PATCH 2/2] Added some cygwin love --- plugins/go-command/go-command.plugin.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/go-command/go-command.plugin.zsh b/plugins/go-command/go-command.plugin.zsh index 383a05356..bfe9bb8bb 100644 --- a/plugins/go-command/go-command.plugin.zsh +++ b/plugins/go-command/go-command.plugin.zsh @@ -9,8 +9,10 @@ go() { else echo "DISPLAY not set: xdg-open requires X11" fi + elif [ -e "`which cygstart`" ]; then + cygstart "$1" else - echo "xdg-open not found: unable to open '$1'" + echo "neither xdg-open nor cygstart found: unable to open '$1'" fi fi elif [ -d "$1" ]; then