Skip to content
This repository was archived by the owner on Mar 3, 2020. It is now read-only.

Commit f44f06e

Browse files
committed
Consolidate project and go project autocompletion
I wanted to be able to use `c` to jump around any one of my projects, no matter what the directory structure may be required of them (lol go). Hopefully this won't break for those that don't have Go set up, and hopefully it's a decent example on how to expand your own completion a bit further.
1 parent ae0ff14 commit f44f06e

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

‎functions/_c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
# See further documentation in `functions/c`.
2+
#
13
#compdef c
2-
_files -W $PROJECTS -/
4+
_files -W $PROJECTS -/
5+
_files -W $GOPATH/src/github.com -/

‎functions/c‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
1-
cd $PROJECTS/$1;
1+
#!/bin/zsh
2+
#
3+
# This lets you quickly jump into a project directory.
4+
#
5+
# Type:
6+
#
7+
# c <tab>
8+
#
9+
# ...to autocomplete on all of your projects in the directories specified in
10+
# `functions/_c`. Typically I'm using it like:
11+
#
12+
# c holm<tab>/bo<tab>
13+
#
14+
# ...to quickly jump into holman/boom, for example.
15+
#
16+
# This also accounts for how Go structures its projects. For example, it will
17+
# autocomplete both on $PROJECTS, and also assume you want to autocomplete on
18+
# your Go projects in $GOPATH/src.
19+
20+
if [ ! -z "$1" ] && [ -s "$GOPATH/src/github.com/$1" ]; then
21+
cd "$GOPATH/src/github.com/$1"
22+
else
23+
cd "$PROJECTS/$1"
24+
fi

‎go/path.zsh‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export GOPATH=$PROJECTS/go
2+
export PATH="$GOPATH/bin:$PATH"

0 commit comments

Comments
 (0)