1
ABOUT
2
-----
3
4
This is bash completion support for osc (openSUSE build service
5
command-line tool).
6
7
8
DOWNLOAD
9
--------
10
11
The project is hosted on gitorious.org. To get the latest version,
12
use the following command:
13
14
git clone git://gitorious.org/opensuse/osc-bash-completion.git
15
16
17
INSTALLATION
18
------------
19
20
A)
21
If you have bash-completion package installed and enabled, you can
22
copy the osc.sh file into /etc/bash_completion.d directory. Then open
23
new terminal (so that the completion script) gets loaded and osc
24
completion should work.
25
26
B)
27
If you don't have bash-completion installed or you don't want to put
28
the completion script in /etc for whatever reason, you can use the
29
completion script as follows:
30
31
1) copy the osc.sh file somewhere (e.g. ~/.osc-completion.sh)
32
2) add the following line to your .bashrc:
33
   source ~/.osc-completion.sh
34
35
For the time being, the script does not check osc is installed and
36
properly set up (list password/username stored in ~/.oscrc). So please
37
make sure that osc is installed and working (e.g. by running 'osc ls
38
openSUSE:Factory') before trying the completion.
39
40
You might also want to look at how you can customize the completion:
41
see CUSTOMIZATION section.
42
43
44
REQUIREMENTS
45
------------
46
47
Working osc installation is needed. Tested with osc-0.130git. It
48
should more or less work with other osc versions as well. I plan to
49
make future versions less dependent on osc-version.
50
51
The script works with bash-4.x. I have no idea if it might work/works
52
with other shells too (but I doubt so). If the changes to make it
53
compatible with other shells were not too intrusive, I'll be happy
54
to accept patches ;)
55
56
57
FEATURES
58
--------
59
60
The script provides support for completing:
61
 * osc subcommand names (checkout, commit, ...)
62
 * global long osc options (e.g. --quiet, --debug, ...)
63
 * long subcommand options
64
 * project names
65
 * package names (in given project)
66
 * file names (in given project/package)
67
 * repository names (openSUSE_Factory, ...)
68
 * architectures (i586, x86_64, ...)
69
 * ...
70
71
Examples:
72
 * osc com<tab><tab> => osc commit
73
74
 * osc --ht<tab><tab> => osc --http-debug
75
76
 * osc build --a<tab><tab> => osc build --alternative-project
77
78
 * osc ls Ar<tab><tab> => osc ls Archiving
79
80
 * osc ls Base:System pa<tab><tab> =>  osc ls Base:System parted
81
82
 * osc cat Base:System parted ba<tab><tab> => osc cat Base:System parted baselibs.conf
83
84
 * osc buildlog openSUSE_<tab><tab> => osc buildlog openSUSE_
85
   openSUSE_Factory  openSUSE_11.0     openSUSE_11.1     openSUSE_11.2
86
   - works in package working directory
87
88
 * osc buildlog openSUSE_Factory x<tab><tab> => osc buildlog openSUSE_Factory x86_64
89
       - works in package working directory
90
91
 * osc createrequest -a <tab><tab> => osc createrequest -a
92
   add_role delete change_devel set_bugowner submit
93
94
 * osc ? d<tab><tab> => osc ?
95
   delete deleterequest dependson diff
96
97
 * osc meta a<tab><tab> => osc meta attribute
98
99
 * osc my <tab><tab> => osc my
100
   pkg prj rq sr
101
102
 * osc request <tab><tab> => osc request
103
   accept approvenew co     decline checkout
104
   list   log        revoke show    wipe
105
106
 * osc getpac for<tab><tab> => osc getpac fortune
107
108
109
At the moment, the script DOES NOT provide support for completing:
110
- short options
111
- arguments for most of the options
112
- some complex combinations of arguments (see TODOs in osc.sh)
113
114
Also, the script does not work correctly if there is a long option
115
with argument and there is '=' between the option and argument
116
(--long-option=arg). Please use the '--long-option arg' form instead.
117
Fixing this is in TODO list.
118
119
For the time being, the script does not recognize alternative apiurl
120
(-A|--apiurl) and thus it works only with default
121
(https://api.opensuse.org) api. This is in TODO list as well.
122
123
To avoid long delays and spamming OBS server too much, the script
124
caches several information:
125
- list of projects in
126
  ~/.osc_bash_completion/default/prjlist
127
- list of packages in project in
128
  ~/.osc_bash_completion/default/${prj}_pkglist
129
- list of enabled repositories/architectures
130
  (output of 'osc repos prj') in
131
  ~/.osc_bash_completion/default/${prj}_repos
132
133
The list of projects (prjlist) is generated when needed. It takes several
134
seconds to generate the list, so you'll notice significant delay on
135
the first completion.
136
137
By default, the prjlist contains all projects in the build service.
138
As of this writing, there are more than 13k projects, which make
139
the completion somewhat slow - see CUSTOMIZATION for information how
140
to avoid this.
141
142
The ${prj}_pkglist and ${prj}_repos are generated when needed, only
143
for the given project. For instance, the "osc cat Base:System <tab><tab>"
144
will generate Base:System_pkglist file. Next time, no communication
145
with the OBS server will be necessary. See CUSTOMIZATION for info
146
about keeping the cache up-to-date.
147
148
Note: when completing particular filename in a package (e.g.
149
"osc cat Base:System parted part<tab><tab>"), the list of files
150
in Base:System/parted is not cached anywhere, but is
151
generated on the fly.
152
153
If no completion is found, it defaults to filename completion.
154
155
156
CUSTOMIZATION
157
-------------
158
159
Updating prjlist
160
~~~~~~~~~~~~~~~~
161
162
The completion script provides a mechanism to restrict caching of
163
projects list to some subset of all projects, which makes completion
164
significantly faster and also gives you less options if the completion
165
is ambiguous.
166
167
By default, it caches list of all projects. This behavior can be
168
changed by providing custom script that generates list of projects
169
that you are interested in. If the completion script finds
170
user-provided script named
171
~/.osc_bash_completion/default/prjlist_update.sh, it takes it's output
172
and stores it as prjlist (the script must be executable).
173
174
Having prjlist contain all projects except home:* projects, but
175
including my home projects (home:myusername*) seems to work
176
sufficiently fast, while still including most of the projects
177
I might want to work with. However, any other subset of projects in
178
prjlist should work as well.
179
180
You can use the provided prjlist_update.sh as a template for the
181
script (don't forget to put your OBS username there).
182
183
The drawback of not having all OBS projects in prjlist is that it
184
breaks completion if one of the projects not listed in prjlist appears
185
on the commandline (it is not detected as being a project name and the
186
completion logic breaks).
187
188
The completion script does never update the prjlist [*]. For this
189
reason, it might be appropriate to update the prjlist regularly as a
190
cronjob. To make prjlist update once a day, put following line to your
191
crontab:
192
193
30 3 * * * ~/.osc_bash_completion/default/prjlist_update.sh > ~/.osc_bash_completion/default/prjlist
194
195
Please use some random time, so that we don't overload OBS if this
196
becomes too popular :)
197
198
[*] However, this will probably change in the future, so that
199
the completion script will update the prjlist on its own if
200
it detects that the prjlist is too old.
201
202
Updating *_{pkglist,repos}
203
~~~~~~~~~~~~~~~~~~~~~~~~~~
204
205
Similarly, the ${prj}_pkglist and ${prj}_repos files are
206
never updated by the osc completion script after they are created.
207
You can use provided update_prjs_cache.sh, which is a simple script
208
that updates all ~/.osc_bash_completion/default*_{prjlist,repos}
209
files. Suitable for running as a cronjob:
210
211
31 3 * * * /path/to/update_prjs_cache.sh
212
213
214
Only one <tab> for completion
215
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
216
217
By default, the bash/readline requires you to hit <tab> key twice
218
before completing the word. If you prefer to hit it only once, put the
219
following into your ~/.inputrc:
220
221
set show-all-if-ambiguous on
222
223
See readline(3) for more details.
224
225
226
KNOWN PROBLEMS, TODO
227
--------------------
228
229
See TODO file
230
231
232
CONTRIBUTING
233
------------
234
Send all patches, suggestions, bug reports and constructive criticism
235
to the current maintainer: Petr Uzel <petr.uzel@suse.cz>
236
You can also try to contact the author on IRC: ptr_uzl @ freenode.net
237
238
Please send the patches in the "git format-patch ..." form if
239
possible. Nice HOWTO is here:
240
http://git.savannah.gnu.org/cgit/coreutils.git/plain/HACKING
241
242
243
--
244
Petr Uzel <petr.uzel@suse.cz>
245
ptr_uzl @ freenode.net