On Thu, Apr 1, 2010 at 9:46 AM, David Frascone <[email protected]> wrote:
>
> There's a really cool feature in zsh that allows you to uniquely add a
> string to the path, if it did not exist before:
>
> typeset -U path
>
> This makes all items in path have to be unique, so then, if you do:
>
> path=(/foo/bin $path)
> path=(/foot/bin $path)
>
> You will NOT have two /foo/bin(s) in your path.
>
> Is there an equivalent way to do this in fish?

Not that I know of. Fish is designed to have a minimal set of builtins
that are as orthogonal as possible. But it might be useful to define a
function like:

function varuniq --description "Return the unique arguments, merging
to the first occurrence of a word."
    for x in $argv;
        if not contains $x $ret
            set ret $ret $y
        end
    end
end

Then use it like this:

set PATH (varuniq $PATH /home/joe/bin home/joe/src)


Or define:

function typeset
    set rest argv[(seq 2 (count $argv))]
    set $argv[1] (varuniq $argv[1] $rest)
end


Or even:

function path
    for x in argv
        if test -f $x and not contains $PATH $x
            set PATH $PATH $x
        end
    end
end

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to