Re: [Fish-users] Completion on alias

2013-11-12 Thread justin
But with aliases like `gco`, the git completion wouldn't even fire.


On Mon, Nov 11, 2013 at 11:56 PM, Mandeep Sandhu <
mandeepsandhu@gmail.com> wrote:

> I think  the reason completion is not working is because of this line
> in share/completions/git.fish:
>
> function __fish_git_using_command
> ...
> # aliased command
> set -l aliased (command git config --get "alias.$cmd[2]" ^
> /dev/null | sed 's/ .*$//')
> ...
>
> So this is basically looking for aliases created via git itself ('git
> config alias.gco checkout' etc).
>
> To fix your issue, you either need to define an alias with git, or
> modify the __fish_git_using_command function to check if the given
> command is a shell alias and return 0.
>
> HTH,
> -mandeep
>
>
> On Tue, Nov 12, 2013 at 1:51 AM, Leira Hua  wrote:
> > I used to use some git aliases in zsh like this one:
> >
> > alias gco='git checkout'.
> >
> > I just switched to fish, and ported the these aliases to fish. Then I
> found a
> > completion issue, maybe caused by the reason that fish doesn't support
> "real"
> > alias. Here is my understanding:
> >
> > In zsh, it knows gco is simply an alias to git, when using tab to
> complete, it
> > will use git's completion.
> >
> > While in fish, gco becomes a function, and for a function, it expect a
> totally
> > different completion rather than git itself, so it lost the completion
> of git,
> > and we might have to redefine the completion for gco function.
> >
> > I do love fish's philosophy of orthogonality, and unify alias and
> function is
> > also a good idea.  I'm not familiar with the completion system of fish
> yet, but
> > I think there might be some trick in alias function can be done, that
> "assign"
> > the completion of the aliased command to the alias function, then solve
> this
> > problem once and for all. Is it possible yet?
> >
> > Thanks, Leira Hua
> >
> >
> >
> >
> --
> > November Webinars for C, C++, Fortran Developers
> > Accelerate application performance with scalable programming models.
> Explore
> > techniques for threading, error checking, porting, and tuning. Get the
> most
> > from the latest Intel processors and coprocessors. See abstracts and
> register
> >
> http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
> > ___
> > Fish-users mailing list
> > Fish-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/fish-users
>
>
> --
> November Webinars for C, C++, Fortran Developers
> Accelerate application performance with scalable programming models.
> Explore
> techniques for threading, error checking, porting, and tuning. Get the most
> from the latest Intel processors and coprocessors. See abstracts and
> register
> http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
> ___
> Fish-users mailing list
> Fish-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fish-users
>



-- 
http://justinhileman.com
--
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk___
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users


Re: [Fish-users] Completion on alias

2013-11-12 Thread Leira Hua
Mandeep Sandhu  writes:

> 
> So this is basically looking for aliases created via git itself ('git config
> alias.gco checkout' etc).
> 
> To fix your issue, you either need to define an alias with git, or modify the
> __fish_git_using_command function to check if the given command is a shell
> alias and return 0.
> 
> HTH, -mandeep

Mandeep, you were talking about the git alias, they have to be used as "git
gco" rather than "gco". But I was talking about the common issue that the
aliases in fish doesn't share with the same completion as the original command,
not just for git.

And in fish, even a simple alias as "alias l=ls", "l" won't have ls's
completion, this is really unintuitive.

In fish, the solution for the built in completions is, define a fucntion that
define complections for $cmds in __fish_complete_ls.fish, and for every built
in alias for "ls", like "ll", "la", define a ll.fish and la.fish inside
completion folder with content as simple as: "__fish_complete_ls ll" and
"__fish_complete_ls la". These are for the built ins, if we define another
alias for ls, say "alias l=ls", we have to define a completion file l.fish with
"__fish_complete_ls l". Every alias need a separate completion file. I think
this is really redundant, and against the design philosophy of fish.

And when comes to command supports subcommand like git, it gets even worse,
cause "alias gco=git checkout" is just a subcommand, shouldn't use the same
completion as git the whole command. That's another issue to solve.



--
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
___
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users


Re: [Fish-users] Completion on alias

2013-11-12 Thread David Adam
On Wed, 13 Nov 2013, Leira Hua wrote:
> Mandeep Sandhu  writes:
> 
> > 
> > So this is basically looking for aliases created via git itself ('git config
> > alias.gco checkout' etc).
> > 
> > To fix your issue, you either need to define an alias with git, or modify 
> > the
> > __fish_git_using_command function to check if the given command is a shell
> > alias and return 0.
> > 
> > HTH, -mandeep
> 
> Mandeep, you were talking about the git alias, they have to be used as "git
> gco" rather than "gco". But I was talking about the common issue that the
> aliases in fish doesn't share with the same completion as the original 
> command,
> not just for git.
> 
> And in fish, even a simple alias as "alias l=ls", "l" won't have ls's
> completion, this is really unintuitive.

Yes - there's been some discussion on this on the issue tracker. See 
https://github.com/fish-shell/fish-shell/issues/165 and 
https://github.com/fish-shell/fish-shell/issues/393.

David Adam
zanc...@ucc.gu.uwa.edu.au

--
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
___
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users


Re: [Fish-users] How to exit on error (bash set -e)

2013-11-12 Thread David Adam
> On Sun, Nov 10, 2013 at 8:35 AM, Martin Bähr <
> mba...@email.archlab.tuwien.ac.at> wrote:
> > On Sun, Nov 10, 2013 at 09:09:26PM +0800, David Adam wrote:
> > > I suppose the argument could be made that error handling should be
> > > explicit.
> >
> > hmm, from a programmers perspective, most sensible programming languages
> > crash when there is an error that is not handled.
> >
> > in other words, errors should never be silently ignored.
> > error handling should be explicit, but catching errors without handling
> > them (which fish seems to be doing here) is frowned upon.

Yeah, I agree. Seeing `On Error Resume Next` at the top of VBScript files 
struck fear into the hearts of many sysadmins.

On Sun, 10 Nov 2013, Alex Boisvert wrote:
> I also think ignoring errors should be explicit; the default should be
> exit-on-failure (though I'll understand that it might be too late to change
> due to backward compatibility)

It would definitely have to wait for a new major release of fish, I think.

David Adam
zanc...@ucc.gu.uwa.edu.au--
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk___
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users


Re: [Fish-users] Completion on alias

2013-11-12 Thread Mandeep Sandhu
On Tue, Nov 12, 2013 at 8:57 PM, justin  wrote:
> But with aliases like `gco`, the git completion wouldn't even fire.

You're right! 'gco' won't even trigger the git completion as the
command doesn't have a corresponding completion file. My bad.

-mandeep


>
>
> On Mon, Nov 11, 2013 at 11:56 PM, Mandeep Sandhu
>  wrote:
>>
>> I think  the reason completion is not working is because of this line
>> in share/completions/git.fish:
>>
>> function __fish_git_using_command
>> ...
>> # aliased command
>> set -l aliased (command git config --get "alias.$cmd[2]" ^
>> /dev/null | sed 's/ .*$//')
>> ...
>>
>> So this is basically looking for aliases created via git itself ('git
>> config alias.gco checkout' etc).
>>
>> To fix your issue, you either need to define an alias with git, or
>> modify the __fish_git_using_command function to check if the given
>> command is a shell alias and return 0.
>>
>> HTH,
>> -mandeep
>>
>>
>> On Tue, Nov 12, 2013 at 1:51 AM, Leira Hua  wrote:
>> > I used to use some git aliases in zsh like this one:
>> >
>> > alias gco='git checkout'.
>> >
>> > I just switched to fish, and ported the these aliases to fish. Then I
>> > found a
>> > completion issue, maybe caused by the reason that fish doesn't support
>> > "real"
>> > alias. Here is my understanding:
>> >
>> > In zsh, it knows gco is simply an alias to git, when using tab to
>> > complete, it
>> > will use git's completion.
>> >
>> > While in fish, gco becomes a function, and for a function, it expect a
>> > totally
>> > different completion rather than git itself, so it lost the completion
>> > of git,
>> > and we might have to redefine the completion for gco function.
>> >
>> > I do love fish's philosophy of orthogonality, and unify alias and
>> > function is
>> > also a good idea.  I'm not familiar with the completion system of fish
>> > yet, but
>> > I think there might be some trick in alias function can be done, that
>> > "assign"
>> > the completion of the aliased command to the alias function, then solve
>> > this
>> > problem once and for all. Is it possible yet?
>> >
>> > Thanks, Leira Hua
>> >
>> >
>> >
>> >
>> > --
>> > November Webinars for C, C++, Fortran Developers
>> > Accelerate application performance with scalable programming models.
>> > Explore
>> > techniques for threading, error checking, porting, and tuning. Get the
>> > most
>> > from the latest Intel processors and coprocessors. See abstracts and
>> > register
>> >
>> > http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
>> > ___
>> > Fish-users mailing list
>> > Fish-users@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/fish-users
>>
>>
>> --
>> November Webinars for C, C++, Fortran Developers
>> Accelerate application performance with scalable programming models.
>> Explore
>> techniques for threading, error checking, porting, and tuning. Get the
>> most
>> from the latest Intel processors and coprocessors. See abstracts and
>> register
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
>> ___
>> Fish-users mailing list
>> Fish-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/fish-users
>
>
>
>
> --
> http://justinhileman.com

--
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
___
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users


Re: [Fish-users] Completion on alias

2013-11-12 Thread Mandeep Sandhu
On Wed, Nov 13, 2013 at 6:36 AM, Leira Hua  wrote:
> Mandeep Sandhu  writes:
>
>>
>> So this is basically looking for aliases created via git itself ('git config
>> alias.gco checkout' etc).
>>
>> To fix your issue, you either need to define an alias with git, or modify the
>> __fish_git_using_command function to check if the given command is a shell
>> alias and return 0.
>>
>> HTH, -mandeep
>
> Mandeep, you were talking about the git alias, they have to be used as "git
> gco" rather than "gco". But I was talking about the common issue that the
> aliases in fish doesn't share with the same completion as the original 
> command,
> not just for git.
>
> And in fish, even a simple alias as "alias l=ls", "l" won't have ls's
> completion, this is really unintuitive.

You're right. I misunderstood the way completions were invoked.

>
> In fish, the solution for the built in completions is, define a fucntion that
> define complections for $cmds in __fish_complete_ls.fish, and for every built
> in alias for "ls", like "ll", "la", define a ll.fish and la.fish inside
> completion folder with content as simple as: "__fish_complete_ls ll" and
> "__fish_complete_ls la". These are for the built ins, if we define another
> alias for ls, say "alias l=ls", we have to define a completion file l.fish 
> with
> "__fish_complete_ls l". Every alias need a separate completion file. I think
> this is really redundant, and against the design philosophy of fish.
>
> And when comes to command supports subcommand like git, it gets even worse,
> cause "alias gco=git checkout" is just a subcommand, shouldn't use the same
> completion as git the whole command. That's another issue to solve.
>

Is it possible for fish to check if the command issued is an alias,
and then try and invoke completions on the unaliased command? That way
the existing completions can be reused and we won't have to create new
ones for every alias.

-mandeep


>
>
> --
> DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
> OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
> Free app hosting. Or install the open source package on any LAMP server.
> Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
> http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
> ___
> Fish-users mailing list
> Fish-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fish-users

--
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
___
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users


Re: [Fish-users] How to exit on error (bash set -e)

2013-11-12 Thread Martin Bähr
On Wed, Nov 13, 2013 at 10:49:24AM +0800, David Adam wrote:
> > I also think ignoring errors should be explicit; the default should be
> > exit-on-failure (though I'll understand that it might be too late to change
> > due to backward compatibility)
> It would definitely have to wait for a new major release of fish, I think.

indeed. though i wonder what would be a good path to not surprise anyone
with such a change?

start with printing a warning now?
and educate users on how to write the script so that it doesn't crash?

(how would that look like btw? 
 false; # this would generate a warning first and cause 
an exit later.
 false; or true;# this would catch the warning and error.
 false; or echo $status; true;  # handle the error)
 false; or exit;# force exit, works now, will continue to work 
in the future.

add an option/setting equivalent to bash -e which will turn into a no-op
later, so that people can write scripts in a future-compatible way and
test whether such a change is even feasable.

also, how to check if there is actually a fatal error?
programs use the exit status to convey other information than just an
error. maybe this should only happen on the values given here:

http://tldp.org/LDP/abs/html/exitcodes.html#EXITCODESREF

1   Catchall for general errors
2   Misuse of shell builtins (bash)
126 Command invoked cannot execute
127 "command not found"  
128 Invalid argument to exit
128+n   Fatal error signal "n" 
130 Script terminated by Control-C (abd also by ctrl-z)
255*Exit status out of range

this is more complex that it looked initially.

greetings, martin.
-- 
eKita   -   the online platform for your entire academic life
hackerspace beijing -http://qike.info
--
chief engineer   eKita.co
pike programmer  pike.lysator.liu.se  caudium.net
foresight developer  realss.comforesightlinux.org
unix sysadmintrainer   developersocietyserver.org
Martin Bähr  working in chinahttp://societyserver.org/mbaehr/

--
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
___
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users