shell function which allows you to tag files by creating symbolic links directories in a 'tags' folder.

tag() { local t="$HOME/tags/$1"; [ -d $t ] || mkdir -p $t; shift; ln $* $t;}
The tag function takes a tag name as its first argument, then a list of files which take that tag. The directory $HOME/tags/tagname will then hold symbolic links to each of the tagged files. This function was inspired by tmsu (found at Example: tag dog airedale.txt .shizturc This will create $HOME/tags/dog which contains symbolic links to airedale.txt .shizturc and

By: bartonski
2012-02-08 12:40:45

1 Alternatives + Submit Alt

What Others Think

But it only works with arguments with absolue paths, if you use relativa paths the links will only works in the same directory where the tags were created.
flxndn · 479 weeks and 4 days ago
Egad, that's frustrating... hard to fix in a one-liner.
bartonski · 479 weeks and 4 days ago
changed call to ln so that it creates hard links rather than symbolic... not being able to use relative paths is more of a hindrance (for me) than not being able to tag files across file systems.
bartonski · 479 weeks and 4 days ago
flxdn: I assume your full path function was to fix the issue? I'm holding off on posting the alternative using readlink.
MeanderingCode · 479 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: