I have the following code in my .Zshrc
function google; {
$VIEW "http://www.google.com/search?q='url-encode "${(j: :)#}"'"
}
I get
google masi
google:1: no such file or directory: http://www.google.com/search?q='url-encode masi'
How can you get Google Search to work in Zsh?
The following solves the problem in Mac
function google; {
open "http://www.google.com/search?q='url-encode "${(j: :)#}"'"
}
and in Ubuntu
function google; {
gnome-open "http://www.google.com/search?q='url-encode "${(j: :)#}"'"
}
Don't know anything about zsh but looks like you've got a problem with your quotes.
Looks like it evaluates the url to being
http://www.google.com/search?q='url-encode masi'
Which probably isn't what you were after. (url encoded version of 'masi') ?
What's the value of $VIEW?
Set it to the path of a web browser or downloader.
Related
Does anyone have experience changing the default browser for atom-live-server? The documentation says to add, {"browser" : "browser-name"}, to atom-live-server.json. I did that and the default live server browser did not change from Chrome which is my default browser for macos 10.14.1. Here is the atom-live-server.json file, but it didn't work.
{
"atom-workspace": {
"ctrl-alt-3": "atom-live-server:start-3000",
"ctrl-alt-4": "atom-live-server:start-4000",
"ctrl-alt-5": "atom-live-server:start-5000",
"ctrl-alt-8": "atom-live-server:start-8000",
"ctrl-alt-9": "atom-live-server:start-9000",
"ctrl-alt-l": "atom-live-server:startServer",
"ctrl-alt-q": "atom-live-server:stopServer"
}
{
"browser" : "Firefox"
}
}
Does atom-live-server always use the macos default browser so you can't actually change it?
Thanks for your help.
It looks like this is caused by a simple syntax error in your JSON file. You need to separate keys with a comma. Your file should look like the following (note the comma on line 10):
{
"atom-workspace": {
"ctrl-alt-3": "atom-live-server:start-3000",
"ctrl-alt-4": "atom-live-server:start-4000",
"ctrl-alt-5": "atom-live-server:start-5000",
"ctrl-alt-8": "atom-live-server:start-8000",
"ctrl-alt-9": "atom-live-server:start-9000",
"ctrl-alt-l": "atom-live-server:startServer",
"ctrl-alt-q": "atom-live-server:stopServer"
},
{
"browser" : "Firefox"
}
}
I think you just need to put the following code in your .atom-live-server.json file. This file should be in your project folder.
{
"browser" : "Firefox"
}
It works on my windows 7 system. The first few lines seem to make things worse. I don't know why.
I think you've solved somehow, but I wrote this answer because I got in same situation.
(I work on Mac OS Mojave)
I did the same way Bill Zhao said.
Create a json file .atom-live-server.json in project file, and put
{
"browser":"Firefox(or firefox)"
}
It's working for me. July 6 2019
Only change your predetermined browser in your operating system.
Simple question :
I am using cmder and i would like to be able to define ~(or ~USERID) as my %USERPROFILE% environment variables. I edited %CMDERROOT%\config\aliases to add this line : ~=%USERPROFILE% it does work for ls command but not for cd for instance.
Is there a better way to have this unix-like user profile aliases ?
For those who would like an answer to that question, it have been addressed in the following github issue :
https://github.com/cmderdev/cmder/issues/41
Not a direct answer, but a decent work-around was mentioned in the discussion on that page:
clink, the vendor package that would handle this has a similar issue report marked as "wontfix" So, here's the workaround
I'm using an AutoHotKey script for that:
#IfWinActive ahk_class VirtualConsoleClass
::~::D:/nicolas
#IfWinActive
It replaces automatically ~ with D:/nicolas in ConEmu console (and only ConEmu console)
I have not tried it in a script executed from the command line, but it works from the command line directly, as nicolas suggests.
I don´t remember where I got it but add these lines to your profile:
function cuserprofile { Set-Location ~ }
Set-Alias ~ cuserprofile -Option AllScope
you just hit ~ (enter) and you'll send to your home directory.
PS. I'm using PowerShell in cmder, regards.
My AutoIt script launches another script (written in UIAutomation). So I wrote this:
RunWait("C:\AutoUIInst\Test\bin\Debug\" & "Test.exe", "","")
It works fine. But now I have to add a parameter. For example: "Test.exe -someParam" . So i tried RunWait() :
RunWait('"C:\AutoUIInst\Test\bin\Debug\" & "Test.exe" -someParam', "","")
That won't work. Can someone help?
Maybe there is only a space missing right before the paramter.
RunWait("C:\AutoUIInst\Test\bin\Debug\Test.exe -someParam", "","")
You can also try ShellexecuteWait which also has a Parameter option!
I had similar problems some time ago when running another applications from my script and I solved it by using ShellExecuteWait. You can rewrite your call like this:
ShellExecuteWait("C:\AutoUIInst\Test\bin\Debug\Test.exe", "-someParam")
I find that developing functions in IPython notebook allows me to work quickly. When I'm happy with the results I copy-paste to a file. The autoindent is 4 spaces, but the coding style for indentation at my company is 2 spaces. How do I change the autoindent to 2 spaces?
The official documentation has an example answering this specific question. This worked for me with IPython 4.
Summary: Paste the following into your browser's javascript console
var cell = Jupyter.notebook.get_selected_cell();
var config = cell.config;
var patch = {
CodeCell:{
cm_config:{indentUnit:2}
}
}
config.update(patch)
The setting is persisted. You can roll back by exchanging : 2 for : null.
From the official documentation for CodeMirror Code Cells:
Open an Ipython Notebook
Create a Code Cell e.g. by pressing b
Open your browser’s JavaScript console and run the following
snippet:
var cell = Jupyter.notebook.get_selected_cell();
var config = cell.config;
var patch = {
CodeCell:{
cm_config:{indentUnit:2}
}
}
config.update(patch)
Reload the notebook page in the browser e.g. by pressing F5
This will fix it permanently. I assume this works only on recent versions, not sure though!
AdamAL's answer is correct. It worked for me.
However it only changes the indentation in the Jupyter Notebook and leaves the indentation in the Jupyter Editor unaffected.
A more direct way to change the indentation is to directly edit the Jupyter config files in the .jupyter/nbconfig directory. This directory contains 2 files:
edit.json
notebook.json
The option you must set in either one is indentUnit. Here is the content of my Jupyter config files:
edit.json:
{
"Editor": {
"codemirror_options": {
"indentUnit": 2,
"vimMode": false,
"keyMap": "default"
}
}
}
notebook.json:
{
"CodeCell": {
"cm_config": {
"indentUnit": 2
}
}
}
With this approach I've set the default indentation to 2 in both the Jupyter Notebook and the Jupyter Editor.
Based on this question and the options found here:
In your custom.js file (location depends on your OS) put
IPython.Cell.options_default.cm_config.indentUnit = 2;
On my machine the file is located in ~/.ipython/profile_default/static/custom
Update:
In IPython 3 the plain call does not work any more, thus it is required to place the setting within an appropriate event handler. A possible solution could look like
define([
'base/js/namespace',
'base/js/events'
],
function(IPython, events) {
events.on("app_initialized.NotebookApp",
function () {
IPython.Cell.options_default.cm_config.indentUnit = 2;
}
);
}
);
If you use jupyterlab, there seems to be an easier way:
1) Click jupyterlab menu Settings > Advanced Setting Editor
2) Click "Notebook" on the left hand pane, make sure you are on "Raw View"
3) On the right pane, under "User Overrides", enter this:
{
"codeCellConfig": {
"tabSize": 2
}
}
If you look at the System Defaults, that will give you hint on whats overridable and you can repeat this for other settings.
I tried this on Google Platform AI Notebook which uses Jupyterlab.
I believe this is now best wrapped in a event handler to load once per notebook load:
$([IPython.events]).on('app_initialized.NotebookApp', function(){
IPython.CodeCell.options_default['cm_config']['indentUnit'] = 2;
});
In addition to adding
IPython.Cell.options_default.cm_config.indentUnit = 2;
to your custom.js file as suggested by Jakob, be sure to clear your browser cache as well before restarting ipython notebook!
Also, you may have to first create the ~/.config/ipython/profile_default/static/custom/ directory (use echo $(ipython locate default) to find your default directory) before adding the custom.js file.
I'm using oh-my-zsh and wanted to write a small plugin which would executes command autoamtically when i switch directories. So for example I will have to some kind of mapping like
/Users/ed1t/Dropbox="echo Entering Dropbox Directory"
I could write a function cd() to do this but is that the efficient way of doing it?
I think you're looking for the chpwd hook function.
chpwd () {
echo "Changing directory from $OLDPWD to $PWD"
}