If there are a several functions for common hosts, you can also add different paths to fish_function_path in your config.fish and place functions there:
switch (hostname) case host1 set fish_function_path $fish_function_path /path/to/host1/functions case host2 set fish_function_path $fish_function_path /path/to/host2/functions case 'host_*' set fish_function_path $fish_function_path /path/to/host_N/functions end Maxim On Wed, 27 Jun 2012 11:30:28 +0400, Christopher Wright <dhase...@gmail.com> wrote: > Try this pattern: > > # .config/fish/functions/mybox.fish > function mybox > ssh mybox.example.com $argv > end > > # .config/fish/config.fish > if test (hostname) == "mybox" > functions -e mybox > end > > ...except for `functions -e` not working yet (at least for me; am I on > master?). > > Quoting Elis Axelsson (2012-06-26 09:37:27) >> Hello fishermans ;) >> >> In my case, I have a repo for my home-folder. Which I have on almost >> all my boxes to keep my configs synced. I also like to make "aliases" >> for ssh to some different boxes, so I just type the name of the box in >> my fish and I get there. >> >> And It's very very rare that I want to ssh to localhost, so I fired up >> a texteditor and added if-statements depending on hostname to make a >> function or not in my ~/.config/fish/function/*fish files... like >> this: >> if test (hostname) != "mybox" >> function mybox >> ssh mybox.example.com $argv >> end >> end >> >> This works well, until I want to funced that function on any box, I >> have to do it by hand in the file. The inline-editor does not do it >> for me if I have if-statement outside of the function-declaration. But >> that's fine. >> >> So to my suggestion: >> >> To introduce --hosts on function >> >> And that you can have multiple hosts separated by comma and that you >> can have wildcard * for any host, and have like "!myhost42" to say >> "don't make this function available on hosts with the name myhost42" >> >> Like this: >> >> function mybox --hosts *,!mybox >> ssh mybox.example.com $argv >> end >> >> -- >> Elis "etu" Axelsson >> >> ------------------------------------------------------------------------------ >> 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 ------------------------------------------------------------------------------ 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