[Fish-users] Fish scripting wishlist
During the process of porting __git_ps1 to Fish (see my previous email), I ran into lots of issues (both design issues and missing functionality) with Fish scripting. I've already filed issues for a lot of these, but I thought I would just try to round them all up. These are in no particular order: 1. Fish seriously needs some facility for doing basic string manipulation. Farming out to other processes is rather slow and complicated. In fact, when I needed to replicate bash's functionality for ${somevar#strip/prefix}, it turned out the easiest way to do that was in fact to use bash again, with (/bin/sh -c 'echo ${1#strip/prefix}' -- $somevar). Farming out to other programs to do work, as slow as it is, is at least understandable, but having to actually farm out to bash itself seems completely wrongheaded. 2. Fish could really use an equivalent for bash's ${var:-value} syntax. It's very awkward to turn what could be one expression into 4 lines is rather awkward. And in fact in my __fish_git_prompt script, the lack of this functionality ballooned into a lot more work because I didn't want to insert those 4 lines everywhere I needed the simple characters. See the __fish_git_prompt_validate_chars function from my __fish_git_prompt.fish script, along with the extra event handler to invalidate those variables. This functionality could have been used to simplify the color variable logic as well. 3. Fish needs a way to do command substitution within a double-quoted string. The simplest solution is probably to support $() within double-quotes. The reasoning is twofold: first, a command substitution that evaluates to no output ends up being stripped entirely from the argument list of its surrounding command. This has extremely bad implications when using it with, e.g. `test -n (some command)`. Second, this would allow for storing the output with its newlines in a variable, instead of having the output be split into multiple elements. And as a bonus it would make it a lot easier to combine command substitution output with other text in the same argument, e.g. $somevar(some command)$anothervar. 4. Fish needs basic math. Farming math out to `bc` is extremely slow. 5. Fish needs a way to do string testing with pattern matching, e.g. the == operator from bash's [[ builtin. 6. We need 'else if'. I can't figure out why that was omitted. 7. A command substitution should be allowed to modify the $status of its surrounding context. It's currently documented as not touching $status, although this documentation is fairly unnecessary because if it did modify $status, that would simply be overwritten by the status of the command that it's being passed as an argument to. However, once command substitution can modify $status, then the next step is to modify the `set` builtin to not modify $status unless the `-q` flag was provided. With both of these changes, I can then store the command output into a variable and act on its status. In bash, this is trivial: if foo=$(some command); then # the command substitution exited 0 fi In Fish, I'd really like to be able to say if set foo (some command) # the command substitution exited 0 end Instead I have to use the awkward construct set -l oldStatus set foo (some command; set oldStatus $status) if test $oldStatus -ne 0 # the command substitution exited 0 end -Kevin -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users
Re: [Fish-users] vi-mode WIP
Ian, thank you for tackling this!! vi mode is highly desired by other users, but I don't know enough about it to implement it. Regarding repainting, does 'commandline -f repaint' work? _fish On Jun 21, 2012, at 12:03 AM, Ian Munsie wrote: your vi-mode works wonderful. I've only the problem with the 'w' and 'e' keys, which place the cursor to the space, rather the last/first letter in the word. Yes, for now I'm just using the built in forward/backward-word commands for them as they were close enough to get started. The 'W' and 'E' commands I've implemented myself and (barring a few edge cases) should place the cursor in the right place. I need to implement 'w' and 'e' (and change 'W' and 'E') so they work as directional modifiers as well as for navigation, so the correct functionality is coming :) It would be also good to have the mode indicator. The variable that I can put to the fish_prompt. Done. If you grab the latest version there is now a vi_mode variable that you can use with something like this: function fish_prompt -d Write out the prompt printf '%s@%s%s%s%s [%s] ' (whoami) (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) $vi_mode It currently gets set to one of 'I' (insert), ' ' (normal), 'R' (overwrite) and 'r' (replace single). I'm open to feedback on whether they are appropriate choices. I ran into some trouble implementing this - I couldn't get the prompt to repaint when going into normal mode (yet worked fine when entering insert mode). I eventually figured out that 'bind '' self-insert' seems to be required for this to work for some reason... so now normal mode does that, then binds all printable 7-bit ASCII characters to do nothing before assigning the real bindings - a bit wasteful and ugly, so if anyone can suggest a better way to solve this, please let me know. Cheers, -Ian -- http://sites.google.com/site/DarkStarJunkSpace -- http://darkstarshout.blogspot.com/ -- On the day *I* go to work for Microsoft, faint oinking sounds will be heard from far overhead, the moon will not merely turn blue but develop polkadots, and hell will freeze over so solid the brimstone will go superconductive. -- Eric S. Raymond, 2005 -- Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users
[Fish-users] vim syntax for fish files
I have created a simple vim script for fish highlighting I have added fish keywords to 'sh'. (so it's based on sh filetype) and your auto commenting plugin will work for fish files script is here: http://www.vim.org/scripts/script.php?script_id=4106 -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users
Re: [Fish-users] Fish scripting wishlist
Hello Kevin, Thank you for taking the time to write this up! Your git script looks very ambitious, and so this is thoughtful, informed feedback. (Incidentally I just merged your git script changes). Let me respond to each point in turn: 1.2. 3.: Regarding string manipulation: I'm in favor of doing something here, as long as it keeps in fish's spirit. i.e. definitely do NOT adopt the POSIX specification for variable modifiers, like ${a##*/} to strip all leading path components from $a. That's just line noise, and we can do way better. I also like your suggestion of supporting $(…), especially because this is currently a syntax error, so there's no compatibility risk. There's some synergy between this and string manipulation. There could be a built-in str or munge or whatever that manipulates its argument based on other parameters, e.g. (munge --strip '/*' --repeat $PWD) to get the last component of pwd. But we ought not to invent yet another string manipulation syntax. If anyone has any suggestions for an existing command-based string manipulation syntax that would be appropriate for fish, please share it. 4. Can you elaborate on your math needs? Farming out to bc is slow, but I haven't encountered a case where it matters. 5. Extending builtin test with == for globbing seems reasonable; currently == is a syntax error. Mapping [ to built-in test seems good too. Introducing [[ is bad: [[ does some very magical things to its arguments (like not expanding them) that can't be handled generically. 6. Agreed regarding 'else if'. Any objection to 'elif' as seen in bash, Python, and others? 7. I see your point regarding the difficulty of doing an assign-and-test, but the construct if set foo (some command) … appears to be checking the success of the set command, not of the subcommand. Still I don't have any better suggestions - that's one to think about. _fish On Jun 21, 2012, at 10:58 AM, Kevin Ballard wrote: During the process of porting __git_ps1 to Fish (see my previous email), I ran into lots of issues (both design issues and missing functionality) with Fish scripting. I've already filed issues for a lot of these, but I thought I would just try to round them all up. These are in no particular order: 1. Fish seriously needs some facility for doing basic string manipulation. Farming out to other processes is rather slow and complicated. In fact, when I needed to replicate bash's functionality for ${somevar#strip/prefix}, it turned out the easiest way to do that was in fact to use bash again, with (/bin/sh -c 'echo ${1#strip/prefix}' -- $somevar). Farming out to other programs to do work, as slow as it is, is at least understandable, but having to actually farm out to bash itself seems completely wrongheaded. 2. Fish could really use an equivalent for bash's ${var:-value} syntax. It's very awkward to turn what could be one expression into 4 lines is rather awkward. And in fact in my __fish_git_prompt script, the lack of this functionality ballooned into a lot more work because I didn't want to insert those 4 lines everywhere I needed the simple characters. See the __fish_git_prompt_validate_chars function from my __fish_git_prompt.fish script, along with the extra event handler to invalidate those variables. This functionality could have been used to simplify the color variable logic as well. 3. Fish needs a way to do command substitution within a double-quoted string. The simplest solution is probably to support $() within double-quotes. The reasoning is twofold: first, a command substitution that evaluates to no output ends up being stripped entirely from the argument list of its surrounding command. This has extremely bad implications when using it with, e.g. `test -n (some command)`. Second, this would allow for storing the output with its newlines in a variable, instead of having the output be split into multiple elements. And as a bonus it would make it a lot easier to combine command substitution output with other text in the same argument, e.g. $somevar(some command)$anothervar. 4. Fish needs basic math. Farming math out to `bc` is extremely slow. 5. Fish needs a way to do string testing with pattern matching, e.g. the == operator from bash's [[ builtin. 6. We need 'else if'. I can't figure out why that was omitted. 7. A command substitution should be allowed to modify the $status of its surrounding context. It's currently documented as not touching $status, although this documentation is fairly unnecessary because if it did modify $status, that would simply be overwritten by the status of the command that it's being passed as an argument to. However, once command substitution can modify $status, then the next step is to modify the `set` builtin to not modify $status unless the `-q` flag was provided. With both of these changes, I can then store the command output into a variable and act on its
Re: [Fish-users] I'm not receiving my own messages
On Thu, Jun 21, 2012 at 8:50 PM, Kevin Ballard ke...@sb.org wrote: I don't seem to be receiving my own messages sent to this list, even though I triple-checked my settings and I'm supposed to be getting them. Is anyone else having this problem? I didn't even know I was supposed to receive them. They are in my sent mail. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users
Re: [Fish-users] vi-mode WIP
Regarding repainting, does 'commandline -f repaint' work? It seems that I need both commandline -f repaint and bind '' self-insert for it to work. I'm wondering if the repaint command never goes through without the default binding set - I tried binding just \xe027 (R_REPAINT if I added that up right) to self-insert, but that just threw an error (seems I can't use bind on any sequence 0x7f). Cheers, -Ian -- http://sites.google.com/site/DarkStarJunkSpace -- http://darkstarshout.blogspot.com/ -- On the day *I* go to work for Microsoft, faint oinking sounds will be heard from far overhead, the moon will not merely turn blue but develop polkadots, and hell will freeze over so solid the brimstone will go superconductive. -- Eric S. Raymond, 2005 -- Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users
[Fish-users] bzr completion (and other vcs?)
Hi, I recently started to use fishfish... I'm a bzr user (but obviously also an hg and git one) and I read a previous mail about it (I cannot reply to it since I wasn't subscribed to the list at the time) From the homepage, I assumed that the completion was done by reading the man pages on the fly... by looking into it I found out that actually there's the fish_update_completions builtin function to be called manually if you run it though, it'll create new completions for git: the problem is, those completions don't work out of curiosity, to see if it was feasible to adapt the mercurial completions for bazaar, I found out about the make_vcs_completions in the fishfish sources first thing: if some programs are already known to be better served by some other completions (like the ones for which the completions are generated with such a script), shouldn't it be better if fish_update_completions blacklisted git, hg, svn and such programs? btw, I then tried to use make_vcs_completions to generate bzr completions... but I got lots of errors like: fish: path_get_path( 'bzr' ) bzr: ERROR: No help could be found for 'bzr'. Please use 'bzr help topics' to obtain a list of topics. fish: proc::read_try('bzr $argv; ') I tried to run it with fish -d 3 but I can't understand what is going wrong... I also looked at the make_vcs_completions script itself, by checking it step by step and adding echo statements, but I got lost after line 100, when it seems that it's using a more-than-70 lines long string substitution (or at least, that unmatched single quote seems to be doing that) should make_vcs_completions be rewritten? (it's 2 years old) what is the best approach to get some nice autocompletion for bzr? other people interested out there? should some of this be reported as an issue on github? -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users
[Fish-users] $status in prompt
In my fish_prompt function I added the $status variable, to let me instantly know the exit code of the last command I run (like in the old prompt I was using on zsh) but in my prompt, the value is always stuck to 0 is someone else able to reproduce it? is it a known behaviour? is it a bug? -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users
Re: [Fish-users] $status in prompt
On 22 June 2012 02:43, Tom W. Most tomm...@gmail.com wrote: It works for me, but of course it does need to be referenced in the first statement in the prompt. This is my prompt: Thank you, it works... but it seems a bit unintuitive that it has to be the first statement: I mean, fish_prompt is called each time, so having some other instructions inside would reset the $status, and then I don't see how it could still contain the correct value, after returning from fish_prompt whatever... now I don't have to worry about it anymore, thanks :) -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users
[Fish-users] [PATCH] Fix off by two in move_word left
This can be demonstrated with something like: echo howdy hicontrol-w echo howdy Ialt-b Previously this would delete/move all the way to the start of 'howdy', rather than just the word 'hi'/'I'. It seems that the code to ignore the character under the cursor was redundant, as all the cases I've tried with it removed seem to do the right thing. Signed-off-by: Ian Munsie darkstarsw...@gmail.com --- reader.c |8 1 file changed, 8 deletions(-) diff --git a/reader.c b/reader.c index 139b4ed..0b70e99 100644 --- a/reader.c +++ b/reader.c @@ -2015,14 +2015,6 @@ static void move_word( int dir, int erase, int new ) } /* - When moving left, ignore the character under the cursor - */ - if( !dir ) - { - end_buff_pos+=2*step; - } - - /* Remove all whitespace characters before finding a word */ while( 1 ) -- 1.7.10 -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users
Re: [Fish-users] bzr completion (and other vcs?)
I'd love to see some mercurial toys, like the git and bzr ones I've seen . . . maybe I'll hack something together if I find some time. On Thu, Jun 21, 2012 at 6:16 PM, Dario Bertini berda...@gmail.com wrote: Hi, I recently started to use fishfish... I'm a bzr user (but obviously also an hg and git one) and I read a previous mail about it (I cannot reply to it since I wasn't subscribed to the list at the time) From the homepage, I assumed that the completion was done by reading the man pages on the fly... by looking into it I found out that actually there's the fish_update_completions builtin function to be called manually if you run it though, it'll create new completions for git: the problem is, those completions don't work out of curiosity, to see if it was feasible to adapt the mercurial completions for bazaar, I found out about the make_vcs_completions in the fishfish sources first thing: if some programs are already known to be better served by some other completions (like the ones for which the completions are generated with such a script), shouldn't it be better if fish_update_completions blacklisted git, hg, svn and such programs? btw, I then tried to use make_vcs_completions to generate bzr completions... but I got lots of errors like: fish: path_get_path( 'bzr' ) bzr: ERROR: No help could be found for 'bzr'. Please use 'bzr help topics' to obtain a list of topics. fish: proc::read_try('bzr $argv; ') I tried to run it with fish -d 3 but I can't understand what is going wrong... I also looked at the make_vcs_completions script itself, by checking it step by step and adding echo statements, but I got lost after line 100, when it seems that it's using a more-than-70 lines long string substitution (or at least, that unmatched single quote seems to be doing that) should make_vcs_completions be rewritten? (it's 2 years old) what is the best approach to get some nice autocompletion for bzr? other people interested out there? should some of this be reported as an issue on github? -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users