mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-26 02:12:33 +01:00
Add a "go" command plugin
This commit is contained in:
parent
7c3d12c7de
commit
f45b43a267
1 changed files with 27 additions and 0 deletions
27
plugins/go-command/go-command.plugin.zsh
Normal file
27
plugins/go-command/go-command.plugin.zsh
Normal file
|
|
@ -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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue