Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I always have ~/bin added to the $PATH in my ~/.profile. As is default in Ubuntu.

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

However, when trying out software, hacking together a script, or testing new software that has no PPA's, makefiles and such, I prefer to organize them in directories. For example (I have about twelve of these projects in my ~/bin at this moment):

ber@audrey:~ ☙ ls bin/replicatorg-0033/
contributors.txt  examples  lib-i686    license.txt  readme.txt   scripts        todo.txt
docs              lib       lib-x86_64  machines     replicatorg  skein_engines  tools

This is some java application. replicatorg is the executable.

Now, I could do four things, but I am looking for another, better way:

  1. Symlink the exectuable in ~/bin. ln -s bin/replicatorg-0033/replicatorg bin/replicatorg. This sometimes works, not in this case. The application is poorly written and expects libraries relative to its binary: it will not run when symlinked or copied out of its directory.
  2. Add every subdirectory to $PATH as well. But that means editing ~/.profile everytime I move, download or git-clone new directories.
  3. Install the applications properly systemwide by creating a makefile/install script. Seen as that most of the applications are quick hacks, ugly, in development, scripts and tools, that is not a good idea, IMHO.
  4. Move all the contents of ~/replicatorg-0033/ into ~/bin. Right.

So: how do you organize your ~/bin?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

I create a separate directory for holding packages (~/apps). If there is a program that I want to have in my $PATH, I either create a symlink in ~/bin or create a shellscript wrapper in ~/bin if the program in question does not like symbolic links:

#!/bin/sh
~/apps/package/bin/someprogram "$@"

For larger packages with a lot programs, adding the directory to your $PATH may be more preferable to avoid creating (and forgetting to create) symlinks in ~/bin. This depends on your personal preferences though.

share|improve this answer
    
I like the notion of wrapper shellscripts. It goes well with my other practice to keep vanilla source of applications in ~/src. Thanks! –  berkes May 7 '12 at 12:11
add comment
  1. Add every subdirectory to $PATH as well. But that means editing ~/.profile everytime I move, download or git-clone new directories.

No need to edit every time, try something like this:

if [ -f ~/bin ]; then
   for i in $( find ~/bin -type d ); do
     PATH=$PATH:$i
   done
fi
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.