-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_local_gh.nu
108 lines (88 loc) · 2.25 KB
/
config_local_gh.nu
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# select gist, returns gist url
export def 'gh gist browse' [ ] {
print 'Select Gist to Browse '
let repo = ( gh gist list
| select description id
| input list -d description
)
$"https://gist.github.com/($repo.id)"
}
# select gist to clone here
export def 'gh gist clone' [ ] {
print 'Select Gist to Clone '
let repo = ( gh gist list
| select description id
| input list -d description
)
^gh gist clone $"($repo.id)"
}
# select gist to delete
export def 'gh gist delete' [ ] {
print 'Select Gist to Delete '
let repo = ( gh gist list
| select description id
| input list -d description
)
let areyousure = (
[ "yes" "no" ] | input list "Are you sure? "
)
if $areyousure == "yes" {
^gh gist delete $"($repo.id)"
}
}
# list your gists
export def "gh gist list" [
--files # show file names
] {
let basiclist = ([ $"id(char tab)description(char tab)files(char tab)"
$"visibility(char tab)updated(char newline)"
$"(^gh gist list)" ]
| str join
| from tsv )
if $files == false {
$basiclist
} else {
# par-upsert
# $basiclist | upsert files {|i| ^gh gist view $i.id --files }
let parres = ( $basiclist
| par-each {|i|
^gh gist view $i.id --files
| lines
} )
$basiclist
| merge ( $parres | wrap files )
}
}
# set gist description
export def 'gh gist mv' [ ] {
print 'Select Gist to Change Description (mv)'
let repo = ( gh gist list
| select description id
| input list -d description
)
let newdesc = ( input "New Gist Description: " )
print " you must touch a file and submit now"
^gh gist edit $"($repo.id)" -d $"($newdesc)"
}
# rename a file in a gistdd
export def 'gh gist rename' [ ] {
print 'select gist'
let repo = ( gh gist list
| select description id
| input list -d description
)
let file = ( gh gist list --files
| where id == $repo.id
| get files
| input list "select file"
| get 0 )
let newname = ( input "new file name: " )
run-external gh gist rename $"($repo.id)" $"($file)" $"($newname)"
}
# list your github repositorys
export def "gh repo list" [
] {
^gh repo list
| lines
| parse "{name}\t{description}\t{info}\t{updated}"
}