why can't open the html with chrome in gvim map function? - google-chrome

I have mapped F6 and F7 in vimrc file.
:nnoremap <F6>:w<cr> :!start cmd C:\Program Files (x86)\Google\Chrome\Application\chrome.exe %<CR>
:nnoremap <F7>:w<cr> :exe '!"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" %'<CR>
In CMD ,it works fine for me.
C:\Users\pengsir>"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" g:\\my.html
When i open g:\my.html in gvim and enter into normal status ,press F6 or F7,why my chrome can not open the my.html?
<!DOCTYPE html>
<html>
<HEAD>
<META CHARSET="UTF-8" />
<TITLE> FIRST WEB</TITLE>
<body>
it is my first web
</body>
</html>
When i press F6 IN GVIM ,

Okay, let's solve this step by step:
:nnoremap <F6>:w<cr> :!start cmd C:\Program Files (x86)\Google\Chrome\Application\chrome.exe %<CR>
First, there's whitespace missing between the lhs (<F6>) and the :w... rhs; you're currently mapping the key combo <F6>:w<cr>.
:nnoremap <F6> :w<cr> :!start cmd C:\Program Files (x86)\Google\Chrome\Application\chrome.exe %<CR>
That gives me an open command prompt, but no Chrome. You need to pass either /C or /K so that the remainder is executed as a command; cmd.exe /? tells you this. Let's first use /K to be able to read any errors.
:nnoremap <F6> :w<cr> :!start cmd /K C:\Program Files (x86)\Google\Chrome\Application\chrome.exe %<CR>
I now get 'C:\Program' is not recognized as an internal or external command, operable program or batch file.; we need quoting. We could manually enclose the path in double quotes, but as you probably want to handle any file names passed via %, it's better to let Vim do the quoting. For that, we need :execute (to insert the expressions) and shellescape().
Another hairy quirk of cmd.exe is that once you use quoting, you need to quote the entire command-line again, too. (Don't feel stupid if this is over your head; Microsoft and compatibility down to MS-DOS is to blame for this mess. Vim underwent improvements in that area, too; be sure to use at least a version 7.3.800, or 7.4.)
:nnoremap <F6> :w<cr> :execute '!start cmd /K "' shellescape('C:\Program Files (x86)\Google\Chrome\Application\chrome.exe', 1) shellescape(expand('%'), 1) . '"'<CR>
That one opens the current HTML file in Chrome for me. For finishing touches, just get rid of the left-behind command prompt (/C), and join the two Ex commands, replacing :w with the on-demand :update:
:nnoremap <F6> :update<Bar>execute '!start cmd /C "' shellescape('C:\Program Files (x86)\Google\Chrome\Application\chrome.exe', 1) shellescape(expand('%'), 1) . '"'<CR>
You can make that a bit more resilient by always passing the full absolute path:
:nnoremap <F6> :update<Bar>execute '!start cmd /C "' shellescape('C:\Program Files (x86)\Google\Chrome\Application\chrome.exe', 1) shellescape(expand('%:p'), 1) . '"'<CR>

Related

How to install ESP32 support into Arduino IDE?

Here the link to the page that tells me how to give Arduino the capability to create sketches for my ESP board:
https://github.com/espressif/arduino-esp32/blob/master/docs/arduino-ide/windows.md
open a Git Bash session pointing to ARDUINO_SKETCHBOOK_DIR and execute git submodule update --init --recursive
I have identified the ARDUINO_SKETCHBOOK_DIR from the Arduino IDE. So I do have a path that points from the C:\ drive to this directory. What fails is when I do open GIT Bash and change current directory to the one I have defined as being the ARDUINO_SKETCHBOOK_DIR and do enter the command as shown GIT bash complains "No such file or directory". Effectively this directory is still empty.
Just for completeness of my question. I have followed the instruction on the page whose link I gave to this point where I do no know how to get ahead!
You need to change slashes form "\" to "/" and "C:\" to "c/", and put it in double quotes. Like:
cd "/c/Program Files (x86)/Arduino/hardware/espressif/esp32"

Error: Command failed: C:\Windows\system32\cmd.exe /s /c “rm ./mean/package.json”

How to fix this error. When i use command “yo meanjs”, but not show as in video. It’s:
undefined
You’re using the official MEAN.JS generator.
What mean,js version would you like to generate? i choose 0.4.0
In which filder would you like the project to be generated? mean
Cloning the MEAN repo…
Then it appear error:
Command failed: C:\Windows\system32\cmd.exe /s /c “rm ./mean/package.json”
‘rm’ is not recognized as an internal and external command, operable program or batch file.
you should install git on windown 7 and select folder you want . click -> right mouse -> Git Bash
After type command : "yo meanjs" and everything will good
The tpt2213's answer works, but it can't select menu items of "yo meanjs" with arrow keys.
You need to have cmd.exe with PATH setting, which includes the git command and Unix commands like the rm.
If you install git on window 7 in the folder, "C:\Program Files\Git", set PATH before you run "yo meanjs".
set PATH=C:\Program Files\Git\usr\bin;C:\Program Files\Git\bin;%PATH%
yo meanjs

Silent Uninstall Chrome Isn't Working

I'm creating a batch to automate setting up new computers and one of the programs is AVAST. When I install avast silently, it installs chrome as well. Chrome isn't a program that I'm wanting to put on and it seems there is no workaround. So now I'm trying to make it uninstall chrome silently after AVAST but it just opens a new cmd window instead of running the exe.
#echo off
CD /d "C:\Program Files (x86)\Google\Chrome\Application"
for /r %%f IN (setup.ex?) DO (
START /WAIT "%%f --uninstall --force-uninstall --multi-install --chrome --system-level"
)
pause
Moving the end quotation to the end of %%f just gives an error that --uninstall isn't an existing file.
I've tried this on multiple PC's.
Not sure your still looking for an answer, but I was able to make your batch work.
CD /d "C:\Program Files (x86)\Google\Chrome\Application"
for /r %%f IN (setup.ex?) DO (
"%%f" --uninstall --force-uninstall --multi-install --chrome --system-level
)
This may not be the answer... but it's too long for a comment! Are you certain that you must instqall Chrome? How did you install AVAST? Can we see the command line? If you used some kind of answer file perhaps it can be modified or perhaps you can pass arguments to your install command. Try doing the command with /? to see if you get choices. According to this you do have a choice. https://blog.avast.com/tag/google-chrome/
"As we get close to our launch date for our new Avast! Free Antivirus, version 5 we have an exciting new agreement with Google to announce. Starting in mid-November, we will be giving our new users an option to install Google Chrome when installing Avast. And to be clear here since I think some readers were reading too much into this entry. We are not forcing Chrome on users. It is entirely up to the user–to download/install is entirely up to the user and nothing is hidden."

How do I run a TCL script on files from my file manager?

I'm working on a simple TCL script that makes a few Tk dialogs appear and then compresses a file given by argv. It works just fine from the terminal by running "./script file", but since it's a graphical wrapper for a command-line utility, I want it to run from the right-click menu in a file manager.
I copied it to /usr/bin and used Caja's "Open With Other Application..." option on a random file (no spaces in the path), and entered the name of my script as the application to use. When I tried to open the file this way, there were no dialogs and no archive.
However when I tried to run the script from the terminal again, without the "./", it still worked.
What needs to be done to run a TCL script on a file from the right-click menu and still be platform independant?
Maybe you could start with determining wether Tcl or the file manager is the problem. Write a shell script...
#!/bin/sh
exec rm -- "$#"
...make it executable with chmod +x and try to use it as an "other application" on a file you don't care about. If the file isn't erased, Tcl isn't to blaim.
I have fixed the script in question. I don't know why the dialogs broke or why they are working now, but the archive was apparently failing to appear because the script's working directory was automatically set to my home folder by the file manager.
The code below is what I used to direct my script to the right folder. It changes the working directory to the one containing the file that the script is being run on.
cd [file dirname $argv]
Once I set that, most of my issues seemed to be resolved, and I can now continue dveloping my script.

Windows: How to open a .exe in a shell window that won't close?

I've had this problem for ages, and it's SO ANNOYING.
Suppose I want to run mysqldump.exe... here's my process: Start->run, type "cmd" ... dir into directory after directory until I finally get to c:/program files/mysql/bin/then I can FINALLY call "mysqldump.exe"
I don't mind using Windows Explorer to get to c:/program files/mysql/bin, but then I can't freaking open up any of the .exe files in a shell, and I can't open up shell with the directory being that one.
How can I do this?
This is what I do for those type of commands:
Drag a copy of the "Command Prompt" shortcut onto your desktop.
Open the properties of the shortcut.
Change the Target: field to: %SystemRoot%\system32\cmd.exe /k mysqldump.exe
Change the Start in: field to: c:/program files/mysql/bin/
Hit Ok, then rename the short cut from "Command Prompt" to "Mysqldump".
Then just double click the icon whenever you need that command. The "/k" option for cmd.exe leaves the window open.
Microsoft released a powertoy for Windows XP called Open Command Prompt Here. If you're using Vista, all you need to do is hold shift and right-click.
here's my process: Start->run, type
"cmd" ... dir into directory after
directory until I finally get to
c:/program files/mysql/bin/ then I can
FINALLY call "mysqldump.exe"
Why not just the following?
c:
cd "c:/program files/mysql/bin"
mysqldump.exe
Better yet, put this in a batch file and execute it.
You can also create a shortcut for cmd.exe and set the "Start in" directory to "c:/program files/mysql/bin".
You can download an add-in so that you can right click on the folder and open a command prompt. Saves a lot of time and you say you dont mind navigating to the location.
http://download.microsoft.com/download/whistler/Install/2/WXP/EN-US/CmdHerePowertoySetup.exe
A nice little trick is that the icon in the adress bar of explorer could be dragged to a command line window and it insert the full path at your current cursor position.
It doesn't work in vista but if you SHIFT-RightClick on a folder you have an "Open Command Windows Here" option that appears.
Under xp you could have it by saving this as a .reg and executing it :
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\cmd]
#="Open Command Prompt Here"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\cmd\command]
#="cmd.exe /k pushd %L"
Just use the explorer to navigate to the bin or any directory. then enter cmd at the address bar und hit return. the command line with start at this location.
You can do it with python:
If you don't have activepython already, download from ActiveState's Website. Next, run PythonWin and create a new script. Write the following:
from subprocess import *
Call("c://program files//mysql//bin//mysqldump.exe")
Save the script somewhere. When you want to run it, just doubleclick. There are easier ways if you like writing batch files, but Python is more succinct than even windows for this case.
Just put c:/program files/mysql/bin/ into your path...
Then you can run mysqldump.exe directly without even opening a cmd prompt by typing it into " Start > Run "
I was using the MS PowerToy for a while but moved on to the open source Open Command Prompt Shell Extension because of the key feature:
(copied verbatim from the website)
The ability to open a command prompt in the directory that you are currently in by right-clicking on any empty screen space in the directory. This eliminates the need to navigate up a level in order to open a command prompt in the current directory.
Having to actually click on a folder to open the command prompt using the MS tool was a annoyance for me... especially since I always need to run command line tools on my current directory at the time.