I've run the following lines:
startxwin >/dev/null 2>&1 &
export DISPLAY=:0.0
This switches the default GUI utility from Windows explorer to the x server in case I use this command xdg-open . for opening the current directory. I would like to switch back to Windows explorer. How can I carry it out?
The X server do not open folders, it is a Graphical server for other programs, like xdg-open.
If you need to open explorer on the current directly, instead of xdg-open, just use
$ explorer . &
Or use its full path name
$ which explorer
/cygdrive/c/WINDOWS/explorer
$ /cygdrive/c/WINDOWS/explorer . &
Related
New to Cygwin and trying to launch the batch file from the current working directory. I've done similar things before for .exe files in Windows 10 using the Registry Editor (see link):
https://www.windowscentral.com/how-launch-bash-shell-right-click-context-menu-windows-10
My Cygwin.bat file looks like this:
#echo off
SETLOCAL
set HOME=C:\path\to\home
C:
chdir C:\cygwin64\bin
bash --login -i
ENDLOCAL
However, when I right click on a directory in order to "Open Cygwin.bat here", the terminal opens at C:\path\to\home. How can I make sure the terminal opens in the current working directory?
To obtain the expected result you need to use the chere package.
chere -i
is usually enough to create a proper Bash Prompt Here entry in Explorer left mouse button menu.
Please note that the usage of the cygwin.bat is not recommended anyway as does not use mintty as terminal
I use phpstorm and it's terminal facility.
In terminal section I typed F:\Projects\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico - so it uses Cygwin as terminal. But it opens it in home folder. Is it possible to open it in different folder? By typing a command or by doing something else.
Because I have a folder called F:\Projects\Local in this folder I have vagrant and I want to open phpstorm, open terminal within php storm and just type vagran up. I don't want to open cgywin again.
thanks
If you just want to open Cygwin with Mintty in the project directory then you can execute the command:
F:\Projects\cygwin64\bin\mintty.exe /bin/env CHERE_INVOKING=1 /bin/bash -l
This will avoid automatically changing to the home directory. See https://code.google.com/p/mintty/wiki/Tips#Starting_in_a_particular_directory for more information on this command.
If you want to use the embedded PhpStorm terminal, then you can modify the Shell path in the terminal settings. Open File > Settings... > Tools > Terminal. Replace the shell path with F:\Projects\cygwin64\bin\env.exe CHERE_INVOKING=1 /bin/bash -l. You may need to restart PhpStorm after this change.
Note: this is assuming that your Cygwin Root Directory is F:\Projects\cygwin64\.
For whome the above way ain't work anymore, like in PhpStorm v. 2016.3. The shell path have to be enclosed in quotes
"C:\Users\MyUser\.babun\cygwin\bin\env.exe" CHERE_INVOKING=1 /bin/zsh.exe
For the PhpStorm that I'am using (v10.0.4) in Windows 10 I use this command works:
D:\tools\.babun\cygwin\bin\env.exe CHERE_INVOKING=1 /bin/bash.exe
I'm using Babun which installs the Cygwin in D:\tools\.babun\cygwin.
I have installed mintty. After that I am not able to open gvim. As suggested in same question for emacs I use:
1) mintty gvim
this opens a new window with message :
E233: cannot open displayE852: The child process failed to start the GUI
Press ENTER or type command to continue
Also I have set : export DISPLAY=":0"
what I am doing wrong
You probably don't have an X server running. Look here for instructions on setting it up. Personally, I find it easier to just uninstall the cygwin version of gvim and use the windows version instead.
I had the same problem when starting gvim and was getting the error message as above.
My default DISPLAY setting is :0.0
However, I noticed in the output of my startxwin, that it said
"""
Rules = "base" Model = "pc105" Layout = "us" Variant = "none" Options = "none"
winMultiWindowXMsgProc - DISPLAY=:2.0
winInitMultiWindowWM - DISPLAY=:2.0
winProcEstablishConnection - winInitClipboard returned.
"""
I set my display to :2.0 and it works now.
ie
export DISPLAY=:2.0
Hope this helps.
[Further to this, the script seems to check /tmp/.X11-unix/Xn where n in Xn is a number.
It seems I had X0 and X1 already there, probably leftover from an older bad shutdown.
Deleting this seems to restore it back to using :0.0
]
you can define a function in your .bash_profile (you need to make sure gvim.exe is in your $PATH)
vim() {
echo "cygstart gvim.exe --remote-tab-silent $(cygpath -w "$#")"
cygstart gvim.exe --remote-tab-silent $(cygpath -w "$#")
}
For me, gvim was being picked up from /usr/bin/gvim
I installed gvim as a windows application and then invoked it from its windows path directly as
[cygwin$] /cygdrive/C/Program\ Files\ \(x86\)/Vim/vim74/gvim
And it worked.
Like user2250246, I just punted on trying to get cygwin's gvim to start working again, but I didn't want to type or alias gvim. (Which I probably should've. The alias is easier.)
I added the Windows app's gvim's path to my Windows environment variables:
Get the path to gvim by finding its icon in your Start menu and
right-clicking on it, then opening Properties. Find the Target link
and copy all but the final 'gvim.exe'.
Go to Control Panel -> System -> Advanced System Settings -> Environment
Variables -> System variables. Select Path. Click Edit.
Paste in that path at the start. Click OK. Click OK.
Then Cygwin will put your Windows gvim on its path, but it will put /usr/bin ahead of it on its own path. So
mv /usr/bin/gvim /usr/bin/gvim-screwed-up
mv /usr/bin/gvimdiff /usr/bin/gvimdiff-screwed-up
and your cygwin will find & run the Windows-installed gvim, with or without your cygwin X server running.
Unfortunately, it will no longer load your cygwin .vimrc! You'll have to fix that yourself.
on windows exist command:
start myfile.mp3
start myfile.txt
on mac:
open myfile.mp3
open myfile.txt
Are there analogue command under Ubuntu?
xdg-open if you have a freedesktop.org-compatible environment.
There are several commands in Linux that help you open application associated files. If you know the application to open the file, then this may work . I am not sure if you are looking for this
env DISPLAY=:0.0 firefox "google.com"
opens Firefox with google.com opened in it. You can replace the application name and file name and use this command.
Try "gnome-open", for Gnome powered distros.
gnome-open random-file.torrent will open my torrent app.
Often times, I find myself navigating very deep into a directory and wanting to open the graphical window (nautilus) for various reasons. So the question is simple:
After doing,
cd sampledirectory
cd sampledirectory2
How can I open this location in a GUI?
I assume Gnome with Nautilus:
nautilus .
To open in the current directory.
Replace nautilus with whichever File Manager you use (Dolphin, etc).
The most portable way should be using freedesktop's xdg-utils xdg-open. For example
$ xdg-open .
this has the advantage of choosing from your desktop preferences the tool to open different file types, like for example
$ xdg-open ~/Documents/mypresentation.odp
or
$ xdg-open ~/Pictures/mypic.png
nautilus --no-desktop . &
nautilus .
I've done this a zillion times.
Here is how I do it on every system:
Mac:
#!/bin/sh
open /System/Library/CoreServices/Finder.app ${1:-.}
Linux / BSD, if Gnome:
#!/bin/sh
nautilus ${1:-.}
Windows ... Cygwin ...
#!/bin/sh
[ $# -eq 1 ] && exec explorer "$(cygpath -w "$1")"
Similar to DigitalRoss' comment, on a Mac you can add the following to your ~/.bash_profile:
alias finder="open /System/Library/CoreServices/Finder.app ${1:-.}"
then, from any Terminal window session, you can simply type:
finder
to launch the Finder at your current location.
Surprised that you all not mention:
( dolphin . & )
Detaching programs form the terminal is always key for me because when you close the console window after just do
dolphin . &
... it will also close your file manager or whatever program you started this way together with it and probably nobody wants this.