Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to add the following bash scripts to fish, yet am having trouble getting the syntax in fish right. Here is the original script:

export MINION_INSTALL=$HOME/minion
export NOTES_HOME=$HOME/Notes
export INBOX=$NOTES_HOME/inbox

if [ -d "$MINION_INSTALL" ] ; then
    export PATH="$MINION_INSTALL:$PATH"
fi

source $MINION_INSTALL/aliases_for_minion

And this is the aliases_for_minion file:

alias mn="minion"
alias icannotfind="minion --open --archive --full $@"
alias newnote="minion --new-note $@"
alias open="minion --open $@"
alias remind="minion --new-note --quick $@"
alias summary="minion --count inbox; minion --list --show-tags=False today; \
    minion --count next; minion --count soon; minion --count someday" 

The minion command works fine if I run fish after starting bash.

Any help would be greatly appreciated!

share|improve this question
    
Those are weird bash aliases. Due to the double quotes, the current positional parameters are expanded and essentially hard-coded into the aliases. –  glenn jackman Mar 4 at 0:34

1 Answer 1

up vote 5 down vote accepted

Here's some examples of what this would look like in fish:

set -x INBOX $NOTES_HOME/inbox
if [ -d "$MINION_INSTALL" ]
    set -x PATH $MINION_INSTALL $PATH
end

Note the absence of the quotes, which is especially important in the line that sets PATH. Quoting it would collapse all of the paths in the list to a single entry, which is not what you want.

The aliases are valid in fish, except for the $@ at the end. fish has arguments as $argv, not $@, but more importantly, any arguments are implicitly appended to the alias command. So you can just write:

alias newnote="minion --new-note"

Then, for example, newnote foo bar will become minion --new-note foo bar

If you like, you can verify it with functions newnote, which will show you the function that the alias produced.

Hope that helps!

share|improve this answer
    
Absolutely fantastic! –  montauk Mar 3 at 23:43

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.