np ()
{
/cygdrive/c/Program\ Files/Notepad++/notepad++.exe `cygpath.exe -w "$*"` &
}
Note that it needs to be a function, and not a vanilla alias, because aliases don't allow interpolated arguments. What this function does is open the executable Notepad++ file, then takes a path argument that has been converted from a Cygwin path to a Windows path.
$*
stores the aformentioned arguments that were entered on the command line, and the &
lets the process run in the background. This lets you use Notepad++ from Cygwin without having the shell wait for an exit code. See here for bash scripting info.Reload the shell:
. ~/.bashrc
Now we can open any text file by passing the filename as an argument along with our new alias function. Instead of using vim or another editor we can simply use Notepad++ like so:
np ~/mycooltextfile.txt
You can even create text files this way - by specifying a filename that doesn't exist yet, it will be created for you!
No comments :
Post a Comment