Spaces in Cygwin/bash aliases?

一曲冷凌霜 提交于 2019-12-23 07:31:20

问题


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.


回答1:


Escape Characters:

alias npp="/cygdrive/c/Program\ Files/Notepad++/notepad++.exe"

Edit: Note the change from single to double quotes as well.




回答2:


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.



来源:https://stackoverflow.com/questions/3928312/spaces-in-cygwin-bash-aliases

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!