Passing the current commandline to a zsh autocomplete function - zsh

I track my billable hours. Every item has a description and a number of tags for different clients, projects etc.
Recently I added zsh completion for these tags. This is what I have in my zsh autocompletion file now:
_arguments "*:tags:( $(cat timetrackingdata | extract_tags.py ) )"
The python script extract_tags.py extracts all tags in my timetrackingdata file and gives them back to zsh.
I'd like to able to limit the tags returned by the tags already on the command line
So if I've already put the tag client1 on the command line I want to pass this tag to extract_tags.py so that it can filter it's output and only return tags that occur on items that also have the tag client1.

I think what you are looking for is the $words variable. This is an array of all words specified on the command line that magically exists inside completion functions.
Where is that documented? There are some passing references in man zshcompsys that I would have missed were I not specifically looking for them. However, I found it more clearly highlighted on this website.

Related

how to write query where the input file is passed from the command line (Saxon)

I'm very new to this.
I have a query and an xml file.
I can write a query over that specific file
for $x in doc("file:///C:/Users/Foo/IdeaProjects/XQuery/src/books.xml")/bookstore/book
where $x/price>30
order by $x/title
return $x/title
I have a basic xml file, with books in it, works nicely in intellij.
but if I wanted to run this query against some file defined on the command line, then how do I do it?
the command line for running the above is (as much for other peoples reference)
java -cp C:\Users\Foo\.IdeaIC2019.2\config\plugins\xquery-intellij-plugin\lib\Saxon-HE-9.9.1-7.jar net.sf.saxon.Query -t -q:"C:\Users\Foo\IdeaProjects\XQuery\src\w3schools.com.xqy"
and that also works nicely.
the saxon documentation
https://www.saxonica.com/html/documentation/using-xquery/commandline.html
implies that I can specify an input file, using "-d"
and "The document node of the document is made available to the query as the context item"
but this doesnt really make any sense to my 1 day old XQuery skills.
how do I specify the document is sent from the command line in the query? what is the context item? and how do I reference it?
(I can do a bit of XSLT 1.0, so I understand the notion of a context).
I think the option is named -s (for source) so you can use -s:books.xml and inside your XQuery main expression any path is evaluated with that document as the context item so you can just use e.g.
for $x in /bookstore/book
where $x/price>30
order by $x/title
return $x/title
and the answer is to drop the doc() function
for $x in bookstore/book
i.e. the same notion as xslt.

Disable Jupyter Notebook automatic hyperlink

In my notebook, I print some data from scraped web pages. Some of these are hyperlinks without tags e.g. https://stackoverflow.com. Unfortunately, Notebook prints these out as an actual hyperlink (i.e. wraps it in tags) on the output page and shortens it. (So the final result in HTML looks like this: https://stacko....) The field is set to code, but this still happens. Is there a way to disable this behaviour?
Solution:
Enter the following text in the empty cell of your Jupyter notebook:
%%javascript
Jupyter.utils.autoLinkUrls = function (txt) {
return txt;
}
Explanation:
The ability to locate URLs in text output and convert them to hyperlinks appeared in IPython notebook (a Jupyter's predecessor) as a result of a merge request in Oct' 2012. Since then every piece of output is scanned for URLs and each found URL is replaced with an anchor <a href=.../>. There's no easy way to alter this behavior because function autoLinkUrls(...) doesn't provide any configuration parameters.
So, the only way to disable URL "autolinking" is to simply replace JavaScript function autoLinkUrls, which is exposed through global Jupyter object, and %%javascript magic command makes the job done.

How to change reports or output saving location in robot framework from RIDE

When I run test cases from RIDE the reports are saved in the below path.
C:\Windows\Temp\RIDExf4xla.d
I want save reports in specific path. Can I do this from RIDE? Is there any setting to change the reports location?
Can anyone please suggest the way to do it.
Thanks
Look at the --outputdir command within the Robot Framework Documentation:
Here is what I use:
--outputdir C:/Robot/AutomationLogs/etc/etc --timestampoutputs
You use this one liner on the "Arguments" Field, right on the top of RIDE within the run tab.
From Wamans comment you can add formats to the end of the argument, to also change the dir name dynamically. See the 2nd answer within that SO question. This should be enough for you to get what you're asking for.
There is no way to set this within a UI.
Just set it by pasting that argument option within the "Arguments" Field at the top.
use below code in command line
C:\Tests\> robot -d C:\Test_results Test.robot

Complete directory names using the end of the string on command completition

Let's say I have a directory with the following contents:
/Project.Presentation
/Project.Presentation.API
/Project.Presentation.Web
/Project.Presentation.Infra
/Project.Presentation.Util
I want to do this -> Project.Presentation: API and let it autocomplete to Project.Presentation.API. Inside Project.Presentation to type API and <tab>.
Is it possible to let zsh use this 'forgiving' way of ?
You're overcomplicating your solution.
If you want to execute a command with a file inside these directories, or just cd in one of these directories.
Just write cd (or other command) first, then press tab that will complete Project.Presentation. then you can either write API or write A and press tab.
By the way, you can have a way to navigate through the possibilities with an extra tab key.
Read man zshoptions for to discover options available in zsh.

zsh: completion menu. How to place common part of names?

I have completion menu configured in my zsh. It works great, no problem.
Now I want to make my zsh act like that:
Let's say there are 3 files in a directory:
somefile_first
somefile_second
somefile_third
Now when I press [TAB], I get completion menu with the first file placed in the command line.
But I want zsh to complete the common part of file names (in this example it would be somefile_), do not place anything else after the common part, and let me navigate through completion menu.
How do I do that?
I realize this question is old but I stumbled upon it when looking for the same answer. Here is what I found out.
AFAIK when using completion menu zsh will always place highlighted completion in the command line. However you can make it less hasty.
unsetopt menucomplete
setopt automenu
Changes the behaviour so
first TAB completes the common part
second lists completions without changing command line
third starts the menu and completes command line with highlighted completion
If you prefer no command line changes than fancy menu unset automenu too:
unsetopt menucomplete automenu
That gives bash-like completion. Only common part is completed and propositions are listed.

Resources