Monday, May 6, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 2275  / 3 Years ago, sat, august 14, 2021, 2:20:28

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?


More From » bash

 Answers
2

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 shell script wrapper in ~/bin if the program in question does not like symbolic links:



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


For larger packages with many programs, adding the directory to your $PATH may be preferable to avoid a ~/bin directory with many symlinks to a single project. This depends on your personal preferences though.


[#38671] Saturday, August 14, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
confiorc

Total Points: 42
Total Questions: 121
Total Answers: 123

Location: India
Member since Wed, Aug 26, 2020
4 Years ago
;