add additional custom auto complete to oh-my-zsh plugins - zsh

I recently migrated to oh-my-zsh and would like to add additional method besides the default plugin provided auto complete methods. is there a way I can do it? I know I can use alias but that will not allow to have space in the middle. More over I am looking for an auto complete. Example of what I want to achieve is to add a build function which can be displayed on tab for mvn command so that it will be listed with auto completed.

For autocomplete (from history) you can use the zsh-autosuggestion.
Basically you just clone the git repository to .oh-my-zsh/custom/plugins/ and add zsh-autosuggestions to your plugins list.
Read more here: https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md
Side note is that the built-in mvn plugin gives great autocomplete for commands related to maven.
To install you just add mvn to your list of plugins and omz reload
Then when you type mvn [tab][tab] you get all the supported commands related to mvn. Pretty handy.
I use both plugins. So when typing mvn i get the "previous" mvn command greyed out in the shell so i can run it by typing right-arrow, or select history by using up and down arrow. If continuing to type it will use the mvn plugin to autocomplete commands.
To add additional targets for the mvn plugins, you can edit the plugin yourself.
https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/mvn/mvn.plugin.zsh#L122
Simply add your target text to the reply statement.

Related

Run npm start in Atom Text Editor

In Atom text editor, after saving a file, I'd like to have a hotkey like ctrl-alt-b that will run "npm build" and display the results in an embedded terminal.
I'm also hoping that after seeing the terminal output, I'd be able to click anywhere outside that embedded terminal to make it go away, (instead of having to mouse-travel to some small exit button and click it).
It may be relevant to mention that my OS is Ubuntu 16.04.5.
I did find a really nice tool called the atom build package, but it seems to take over the whole build process, which is something I've already got setup via "npm build".
Setting up a hotkey is the trivial part, but you need some package that provides the actual build command. You can add something like the following to your Atom keymap:
'atom-workspace atom-text-editor:not([mini])':
'ctrl-alt-b': 'package-name:command-name'
Other than that, I recommend using a general purpose package like process-palette. It lets you define a command (or a chain of commands) and run it in your project directory at the press of a custom hotkey.

How to find jupyter <nbextension require path> for Table of Contents (2) extension?

I'd like to install and enable Table of Contents (2) plugin using command-line.
The docs suggest that I can do the following
jupyter nbextension enable <nbextension require path>
How do I find this path for this extension?
Easy solution:
1/ Visit this unofficial list of nbextensions:
https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/nbextensions.html
and pick the extension you want to enable. Say e.g. that I want to enable "Collapsible Headings", then
2/ type:
jupyter nbextension enable collapsible_headings/main
If the extension is enabled you will see an OK message.
So in general type:
jupyter nbextension enable <name_of_extension>/main
Most of the times it will work for you.
Based on #jfbercher's comemnt in jupyter_contrib_nbextensions#947:
jupyter nbextension install <url>/toc2.zip --user
jupyter nbextension enable toc2/main
If a non-default directory is used in nbextensions_configurator, it can be obtained like the code here:
nbextension_dirs = nbapp_webapp.settings['nbextensions_path']
Yeah this does seem like a bit of an oversight. I tried to install the configurator... but had issues.
The approach that worked for me was to look in ~/.local/share/jupyter/nbextensions or similar (you might need to use a docker run image /bin/bash if you are drinking too much koolaid - or your employer is forcing you to. ).
There is then a .js file in various directories which I think correspond to the extension names. E.g. hinterland/hinterland.js means the extension is called hinterland/hinterland.

How to pass cmake arguments using Qt Creator interface and settings

I'm trying to figure out how to use Qt Creator's settings and pass some CMake arguments. Let's say I have an app which I can build using the terminal like so:
cmake .. -DQTDIR=/home/myCustomBuildStuff
-DLD_LIBRARY_PATH=/home/myCustomBuildStuff
-DCMAKE_INCLUDE_PATH=/home/myCustomBuildStuff/include
# etc.
As you can see, I'm using my custom built Qt (plus some other libs). When I build using the terminal, everything works.
But now I want to try to use the Qt Creator and pass all the CMake arguments by using the Qt Creator settings.
I tried to use the CMake Configuration settings that can be found in the Kits. I tried to modify the Build Settings, and add my arguments directly to the Build Steps and/or CMake table above. None of that helps and my app fails to include my custom built QtWidgets from main.cpp:
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5:-1: error:
version 'Qt_5.9' not found (required by home/myCustomBuiltStaff/bin/uic)
In the error above the path is obviously wrong (it needs to search in /home/myCustomBuiltStuff/ folder). But how do I pass that path by using the Qt Creator settings?
Note, I cannot touch the content of the CMake file and only want to make it to build as it builds in my terminal when I pass all the paths as arguments to CMake.
So I followed an advice given in the comment, and had to add my own custom build steps in order to make sure I have the wanted CMake arguments passed correctly. I could not find any other way to pass them by using Qt Creator's settings and menus.
This is the list of steps I did:
Go to Projects and chose the Build to edit. If you have several configurations, you will have to repeat the below steps for each.
Disable or delete the default CMake step, normally it would be something like cmake --build . --target all
Chose your Build directory.
Add new Custom process step with Command to be cmake, Arguments to be your CMake arguments; normally you'd leave the Working directory to default.
Add new Custom process step with Command to be make and add any necessary arguments (e.g. LD_LIBRARY_PATH).
Go and edit the Run settings: make sure the Executable points to the one your cmake and make just created. There you can also add any necessary command line arguments.
This is version 4.3.1 I am using. If not yet done you should have the most updated version of qtcreator.
File->Open:
Choose the CMakeLists.txt file of your project. Select your target and you should be able to get the project open at least.
Now click on "Projects". Assure you have selected Build & Run -> Build and under Cmake click on "Add" -> "String" or "Directory". In your case Directory make more sense. On the left you put the define, without "-D" of course and right side the value.
Repeat the step for every variable you want to define and click on "Apply"
If that does not work I would try to set the CMAKE_EXE_LINKER_FLAGS to -L/home/myCustomBuildStuff
Hint: To see if it worked you can pass VERBOSE=1 parameter to toolparameters if you are using makefiles under the section Build steps. That way your output will show if the variable were really passed.
Hint: Remeber to activate the "Advanced" selection so you see more if not all the variables defined fo Cmake.

Can I use wp-cli to get the Wordpress installation directory?

Can I use wp-cli to return a value for the local Wordpress installation root directory?
Ideally I'd like a wp-cli command like "wp pathname" that returns "user/myname/sites/project_a" when invoked from inside Projects A's installation, and "user/myname/sites/project_b" when invoked inside Project B.
I'm writing a bash script to dump a Wordpress database and do a little post-processing on it. I'm calling on wp-cli to make the dump; I'd also like to use wp-cli to find the pathname for the installation so that I can guarantee than when invoked anywhere in the current installation the dumpfile will always be written to "some/path/to/project_name/dbdumps/". I can't find anything in the documentation about install directory.
wp-cli seems like the right tool for the job because it's Wordpress aware, but I am happy to use some other tool that is capable of discovering my install directory; perhaps a creative and elegant use of the find command, or a way to report the value of Wordpress's FTP_BASE variable?
I ended up doing this with bash, not wp-cli, by using BASH_SOURCE.
There doesn't appear to be a way to do this from within wp-cli itself, but since my script is always running from inside the Wordpress install directory it doesn't matter — I can just find my script's location.

What happened to the TOC extension for ipython notebook?

I'm trying to install the great table of contents extension in a new computer. but I cant find it anymore. the only page I do find does not explain how to install the extension on windows.
So.. How can I install it, and why is it not a part of the official Ipython notebook? I simply can't understand how people are getting along without it.
I've installed toc nbextension successfully with Jupyter 4 (ie. ipython notebook 4) recently.
In fact installing extension is easier than before :)
I post my solution here, may it help.
## download
mkdir toc
cd toc
wget https://raw.githubusercontent.com/minrk/ipython_extensions/master/nbextensions/toc.js
wget https://raw.githubusercontent.com/minrk/ipython_extensions/master/nbextensions/toc.css
## install and enable
cd ..
jupyter-nbextension install --user toc
jupyter-nbextension enable toc/toc
A bit more explain:
install will copy toc to ~/.local/share/jupyter/nbextensions/
enable will modify ~/.jupyter/nbconfig/notebook.json.
You can check these two place to see what happened.
Note: we use enable toc/toc here is because toc.js is in ~/.local/share/jupyter/nbextensions/toc/.
If you put toc.js and toc.css directly in ~/.local/share/jupyter/nbextensions/ then you should use enable toc here.
Edit
Sorry, I didn't notice the orginal problem is on windows. I'm not sure if it's same for windows jupyter, any report is welcome.
Update
Now the toc nbextension has been added into this project which provide a collection of kinds of nbextensions. It's very easy to install and manage, worth to try!
I cannot tell you specific Windows advice, but think the key points should be platform independent:
Create a profile (either a default profile or a named one - you'll probably want default to start).
Locate where the profile is.
Add the custom.js file into the profile.
Edit the custom.js file to point to the notebook extension code.
In a bit more detail, setting up a profile is covered in detail here but for a default profile just go to the command line and enter
ipython profile
Next, locate where your profile is stored by typing at the command line
ipython locate
Call that <profile_dir>.
The rest follows the (Windows equivalent of!) the instructions on the link you have: underneath <profile_dir> navigate to (creating any directories that do not already exist)
<profile_dir>/static/custom/
and add the custom.js file as shown. Then edit the first line, where it has "nbextensions/toc" to point to the location where you have placed the toc.js file you have downloaded. This location is relative to the <profile_dir>; for me I have
<profile_dir>/static/custom/custom.js
<profile_dir>/static/custom/nbextensions/toc.js
<profile_dir>/static/custom/nbextensions/toc.css
and the first line of custom.js reads
require(["/static/custom/nbextensions/toc.js"], function (toc) {
Finally, note that this is with version 1.1.0 of the notebook - if you're using an earlier version I strongly suggest you upgrade before trying this.
You'll also find the official installation instructions at:
https://github.com/minrk/ipython_extensions
These instructions include curl commands for retrieving the toc.js and toc.css files from GitHub, which worked fine for me in a bash shell on linux Mint.
For Windows 7, I used a Git Shell (see http://msysgit.github.io/) to execute the curl commands
This IPython Notebook semi-automatically generates the files for minrk's table of contents in Windows. It does not use the 'curl'-commands or links, but writes the *.js and *.css files directly into your IPython Notebook-profile-directory.
There is a section in the notebook called 'What you need to do' - follow it and have a nice floating table of contents : )
Here is an html version which already shows it:
http://htmlpreview.github.io/?https://github.com/ahambi/140824-TOC/blob/master/A%20floating%20table%20of%20contents.htm

Resources