I am attempting to set up aliases for my Cygwin bash shells, to run programs contained in the standard Windows C:\Program Files subdirectories. Unfortunately, the alias command really doesn't like spaces in a directory name, and nothing I've tried seems to work. I'm trying to get the following running:
alias npp='/cygdrive/c/Program Files/Notepad++/notepad++.exe'
I am currently cheating and using a soft link, but I would prefer to use an alias.
Escape Characters:
alias npp="/cygdrive/c/Program\ Files/Notepad++/notepad++.exe"
Edit: Note the change from single to double quotes as well.
While the answer above will solve the problem, here is another thing you can try:
Use junction utility from microsoft to create a symlink "C:\ProgramFiles" to "C:\Program Files" (and "C:\ProgramFiles86" to "C:\Program Files (x86)")
Sample usage:
C:\>junction C:\ProgramFiles "C:\Program Files"
Amusingly, the link I gave above mentions the exact same case of "Program Files" having a space in it.
Related
I am trying to get a directory listing of only files with a given extension. At first blush this seems to be a simple thing to do, however check out this simple example:
C:\CODE\metcal>dir /b *.exe
metcal.exe
metcal.exe1
Notice that this returns metcal.**exe** and metcal.**exe1** as matches.
With python files a similar thing happens:
C:\CODE\metcal>dir /b *.py
metcal.py
metcal.pyc
Notice again Windows has determined that *.py takes anything that starts with *.py so it captures the .pyc files as well.
Is there a way to get only the extensions that match exactly? In the above python files example I would like the following to occur (obviously with the correct syntax substituted for *.py)
C:\CODE\metcal>dir /b *.py
metcal.py
As a note the matching under Windows not as simple as it seems.
*.exe matches foo.exe, foo.exe1, foo.exeabcde but not foo.exe.bak
There are other questions on SO that are similar that are related to long/short file names. The *.py and *.pyc example here should not introduce name mangling machinery.
**I have experimented on XP and Win7 machines and this behavior is not consistent at the cmd Prompt and file open dialogs. This inconsistant behavior makes me suspect this problem is related to settings of somekind. **
It's because windows wildcards on extensions check both long and short names as explained in this answer:
https://superuser.com/questions/238900/winxp-dir-command-3-and-4-char-extensions-are-the-same#238930
Solution there is to disable 8.3 names creation and then striping them on ntfs volumes which will also improve performance.
Microsoft Docs: Fsutil 8dot3name
Remarks:
Permanently removing 8dot3 file names and not modifying registry keys that point to the 8dot3 file names may lead to unexpected application failures, including the inability to uninstall an application. It is recommended you first back up your directory or volume before you attempt to remove 8dot3 file names.
So if you want to get only those extensions (.py and .pyc), you should try like this way :
#echo off
dir /b *.py*
pause
You can use the Unix ls command from the Windows Subsystem for Linux to do this, assuming you have WSL installed. It's freely available from Microsoft. From your Windows command prompt, type wsl followed by the ls command to list the files you want.
So, for your example, wsl ls metcal.py returns only metcal.py. To get the same results as you're seeing with dir, use wsl ls metcal.py*.
I'm trying to configure Cyberduck to read the Bookmark files from my Dropbox folder.
This is usually accomplished by this command:
defaults write ch.sudo.cyberduck application.support.path ~/Dropbox/Cyberduck
Super easy!!
But... Dropbox has since changed and if you have a Pro Account the Dropbox folder is renamed "Dropbox (Personal)".
I've tried to do this:
defaults write ch.sudo.cyberduck application.support.path ~/Dropbox\ \(Personal\)/
And I get this error:
not parse: [...]/Dropbox (Personal)/Apps/Cyberduck/. Try single-quoting it.
I tried single quoting like this but same error:
defaults write ch.sudo.cyberduck application.support.path '~/Dropbox\ \(Personal\)/'
How can I solve this?
You can single quote escape your parentheses by wrapping them in a double quote:
Instead of: ln -s '/Users/username/Dropbox (Company Name)/' DropboxCompanyName
Do: ln -s "'/Users/username/Dropbox (Company Name)/'" DropboxCompanyName
Notice the double quotes added to /Users/username/Dropbox (Company Name)/
So I cannot find a way to do a "defaults write" to a path with parentheses, but I did this workaround and it seemed to work for me (in my case I needed to link to my enterprise Dropbox account):
cd to your home folder and create a symlink of the directory that has the parentheses:
ln -s '/Users/username/Dropbox (Company Name)/' DropboxCompanyName
At that point, I was able to do do a defaults write that wrote ~/DropboxCompanyName as part of the path and it worked just fine.
All that said, your personal folder already has a hidden symlink: "Dropbox" that's in the same directory and pointing to "Dropbox (Personal)", so you should be able to do you original command as such:
defaults write ch.sudo.cyberduck application.support.path ~/Dropbox/Cyberduck
… because the "Dropbox" part of the path should still lead to your personal folder. This both what I've observed locally (when viewing hidden files) and what Dropbox says on their site: https://www.dropbox.com/help/9031
I am assuming you are using Unix in Terminal.
I have set up a folder of the same name in my Public Folder to test as shown below.
Your current referencing to the folder would seem correct. Dragging the folder into the Terminal window current command line will automatically give you the correct referencing to that folder.
As an alternative I suggest putting the name of the folder in double quotation marks. Even though there are brackets in the name, there is no need to escape these characters in Unix in Terminal in this instance when using double quotation marks. This makes it easier to humanly type the correct reference.
To reference a folder in the image below, for example, the following referencing works for the cd (change directory command):
~/Public/"Dropbox (Personal)"
Hence I suggest try:
ch.sudo.cyberduck application.support.path ~/Public/"Dropbox (Personal)"
As for the rest of this command, I am not sure that ch is a valid Unix command. I do not yet have enough Unix experience to guide you from here.
you have to put "" in the whole address
more like this
ch.sudo.cyberduck application.support.path "~/Public/Dropbox (Personal)"
I am trying to navigate to this below path in cygwin,
C/Program Files (x86)/temp/lfc/utilities
but unfortunately, it shows the below error
$ cd C/Program Files (x86)/temp/lfc/utilities
bash: syntax error near unexpected token `('
Could you please let me know, what is wrong here..
The command:
cd C/Program Files (x86)/temp/lfc/utilities
is trying to call cd with three arguments rather than the correct one:
C/Program
Files
(x86)/temp/lfc/utilities
and the third of those arguments contains characters that cause bash some grief - they're actually defined as metacharacters and, as per the bash doco:
Each of the metacharacters listed above under DEFINITIONS has special meaning to the shell and must be quoted if it is to represent itself.
Just surround the whole lot in quotes, like:
cd '/cygdrive/C/Program Files (x86)/temp/lfc/utilities'
You'll notice I've also prefixed it with the CygWin cygdrive mount point. I'm fairly certain that's still needed, at least from the version I installed a couple of months back.
Cygwin uses POSIX path nomenclature. To easily convert a Windows path into a Cygwin path you can use the cygpath tool:
$ cygpath 'C:\Program Files\foo'
/cygdrive/c/Program Files/foo
Also this tool can convert POSIX path to Windows:
$ cygpath -w '/cygdrive/c/Program Files/foo'
C:\Program Files\foo
A third solution is to drag and drop a file or folder from the Windows explorer directly into your mintty terminal. You will get you Windows path directly converted into the Cygwin's format.
You could also use PROGRA~1, PROGRA~2 and PROGRA~3 like this :
cd /cygdrive/c/PROGRA~1 is equivalent to cd
/cygdrive/c/Programmes
cd /cygdrive/c/PROGRA~2 is equivalent to cd
/cygdrive/c/Program\ Files\ \(x86\)
cd /cygdrive/c/PROGRA~3 is equivalent to cd
/cygdrive/c/ProgramData
You can directly use windows paths with:
cd $(cygpath -u "C:\Program Files (x86)\temp\lfc\utilities")
This is useful for environment variables like:
cd $(cygpath -u "$USERPROFILE")/Downloads
cd "$(cygpath -u "$PROGRAMFILES")/Program Name"
You can know more about cygpath on https://cygwin.com/cygwin-ug-net/cygpath.html
Could you tell me please how to change directory using git bash?
Exactly I want go to C:/Program Files
I type cd c:/ - move to c:/.
I type cd Program Files and I get message that "there is no such directory Program".
So the problem is how to go to the directory name of which consists of two words that are separated by whitespaces.
I'm using Windows 7 operating system.
cd gets just one argument, so if you say cd Program Files it does cd Program. So you need to quote Program Files if you want cd to it as just one argument:
cd "Program Files"
otherwise it is trying to find the directory Program.
You could also type the space as escape seqence:
cd /c/Program\ Files/Git/
Please find below to add windows path in git bash or in unix
export PATH=$PATH:/c/Program\ Files/Java/jdk1.8.0_221/bin:/c/Program\ Files/apache-maven-3.6.1/bin
I am trying to compile code, the makefile created using qmake.
When I run mingw32-make I get the following error:
cd bzip2-1.0.5\ && c:\QtSDK\Desktop\Qt\4.7.3\mingw\bin\qmake.exe c:\Documents an
d Settings\user\My Documents\Visual Studio 2010\Projects\meshlab\meshlab\meshla
b\src\external\bzip2-1.0.5\bzip2-1.0.5.pro -o Makefile
Cannot find file: c:\Documents.
Cannot find file: and.
Cannot find file: Settings\user\My.
Cannot find file: Documents\Visual.
Cannot find file: Studio.
Cannot find file: 2010\Projects\meshlab\meshlab\meshlab\src\external\bzip2-1.0.5
\bzip2-1.0.5.pro.
mingw32-make: *** [bzip2-1.0.5\Makefile] Error 2
By the error it appears that mingw32-make doesn't understand paths that have spaces in them. Is that true? Is there a way around it?
The common way to do it in Linux/UNIX is to escape each space with a backslash, like: /c/Documents\ and\ Settings/User However, this doesn't always work in MinGW.
So, use the short (8.3) name. You get the short name with the Windows (not MinGW) command for %I in (<PATH>) do #echo %~sI where <PATH> can be . (show current directory, like pwd), * (list files in current directory), a particular file path, etc.
Btw, to copy from the awful cmd.exe window, click the icon in the upper-left corner of the title bar, go to Properties, Options, and enable QuickEdit Mode. Then you can select text with your mouse. The Enter key (or menu>Edit>Copy) copies the text to the clipboard. The insert key (or menu>Edit>Paste) pastes it.
From the MinGW "Getting Started" guide:
MinGW may have problems with paths containing spaces, and if not, usually other programs used with MinGW will experience problems with such paths. Thus, we strongly recommend that you do not install MinGW in any location with spaces in the path name reference; i.e. you should avoid installing into any subdirectory of "Program Files" or "My Documents", or the like.
I suspect the same problems found in running executable files will also manifest itself with other files as well. You could try wrapping the whole thing (file specification) inside double quotes and this may work but Windows is sometimes not as logical as UNIX-based shells in this area.
Spaces in file names are evil anyway :-)
Not sure if this helpful or not (in fear of being downvoted), but I created a semantic link in order to avoid paths with spaces. Not sure if it will solve the problem since in my scenario it displayed a different error after I used the semantic link relating to pthreads which I still haven't been able to fix.
Creating semantic link using the command prompt:
mklink /j "C:\newshortcut" "C:\Program Files\Directory with spaces"
Then on the command you want to run, you use C:\newshortcut
Sorry for necroing this, but I had a similar problem and I was able to fix it using cygpath.
For my case I was trying to make an environment variable to visual studio:
export DEVENV="/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/devenv.com
echo $DEVENV
$DEVENV $1 /build "Release|win64"
Which would result in:
/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/devenv.com
-bash: /c/Program: No such file or directory
The solution was to use cygpath -w to convert the path with spaces into an 8.3 filename:
export DEVENV=$(cygpath -w -s "/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/devenv.com")
echo $DEVENV
$DEVENV $1 /build "Release|win64"
Which results in:
C:\PROGRA~2\MICROS~1\2019\COMMUN~1\Common7\IDE\devenv.com
and no error. Hopefully this helps future travellers.