4

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!

1
  • Those are weird bash aliases. Due to the double quotes, the current positional parameters are expanded and essentially hard-coded into the aliases. Commented Mar 4, 2014 at 0:34

1 Answer 1

7

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!

1
  • Absolutely fantastic!
    – montauk
    Commented Mar 3, 2014 at 23:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .