-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd-bashrc.go
46 lines (39 loc) · 898 Bytes
/
cmd-bashrc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"fmt"
"github.com/rwxrob/cmdtab"
)
// extra semicolons for safety depending on how users add to their bashrc
const shell = `
export _sk=$(which sk);
sk () {
case "$1" in
psessions|plog|pinvoice|reserved|genid|bashrc|roll|email|income) $_sk $* ;;
*) if [[ $1 == d ]]; then
shift;
fi
mdir=$($_sk d $*);
if [[ $? == 0 ]]; then
echo $mdir;
cd "$mdir";
fi
;;
esac;
};
export -f sk;
complete -C sk sk;
`
func init() {
_cmd := cmdtab.New("bashrc")
_cmd.Summary = "print the recommended lines to add to a bashrc"
_cmd.Usage = ""
_cmd.Description = `
Prints the lines to add to a bashrc (or simply eval) providing the following:
* Adds the *sk* function
* Adds tab completion *sk*
`
_cmd.Method = func(args []string) error {
fmt.Println(shell)
return nil
}
}