Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For example, having typed:

bash$ java -cp lib/*.jar Something

How to quickly get to

bash$ java -cp lib/library1.jar:lib/library2.jar:lib/library3.jar Something

(or equivalent)

Is there a shortcut like Alt+*, but with ":" instead of " "?

share|improve this question
up vote 1 down vote accepted

This is as convenient as I can muster

CP() { local IFS=:; echo "$*"; }    # perhaps put this in your .bashrc

java -cp "$(CP lib*/jar)" Something
share|improve this answer

Try this. The $(...) construct is command substitution. It runs what's inside and pastes the output back on the command line in its place.

java -cp $(for i in lib/*.jar; do echo -n $sep$i; sep=:; done) Something
share|improve this answer
It is not convenient; it's a little in-place program that is often even longer than just TAB-complete the libraries one by one (I do such things when there are many libraries). Is there a convenient way? Can I add a shortcut like Alt+*, but with other separator? – Vi. Nov 18 '12 at 2:55
this is what Ant or make is for. The way to make it convenient is to use those or to write a bash script and execute it with ./myscript. – memnoch_proxy Nov 4 '13 at 14:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .