How Can I Get MinTTY (Cygwin Terminal) to Open gvim in a New Window? - vim

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.

Related

Open Cygwin.bat file in current working directory (Windows 10)

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

cygwin suddenly not working - default directory now 'cygdrive/c/Windows/system32'

I don't know what happened.
But suddenly, when I open cygwin terminal, I now see :
PF#PF-PC /cygdrive/c/Windows/system32
$
Instead of something like
PF#PF-PC /cygdrive/bin/
$
And now all my commands are not working (like 'ls', 'grep', ...).
What could have happened ? System variables?
Thanks for any help!
EDIT : If I open cygwin by using "bash prompt here" from a windows directory, then all my cygwin works fine.
What's wrong with the normal cygwin ?
EDIT 2 :
See my new comment. The dash (-) at the end of the shortcut is important.
you surely don't have /usr/bin in your path anymore. Please do echo $PATH to see the content of path.
If you do not find /usr/bin go in your .bashrc and add export PATH=/usr/bin:$PATH.
PS : Cygwin always go at first in /cygdrive/c/Windows/system32, you can see it normally by doing cd - after the start of Cygwin to see the last path used.

Problems opening Vim from the command line? (Windows 8)

How do you install Vim such that it runs in the command line?
I saw a post here and it said to make sure that
[✓] Create .bat files for command line use
was checked. I did make sure that it was checked, but vim won't open in the command line. However,
gvim
will open gvim from the command line, which is a pop-up window. How do I open Vim so that I can edit files directly from the command line? I think that I need to edit the PATH, but I don't know what that is or how to edit it.
EDIT: I also looked at this and followed the directions, tailored to my system. Now vimtutor will briefly open the vimtutor for less than a second and close it! But Vim still doesn't work. Gvim will open Gvim still.
EDIT: I don't think I was clear when I wrote my post. Running
vim
does not open Vim on my computer. Neither does
vim.exe
Use the bottom right Win8 gesture and go as following: Settings > PC Info > Advanced System Settings > Advanced > Environment Variables. Under system variables find Path in the list.
Path is just a semicolon separated list of directories. Append vim.exe to the list and it's now in your path.
You want to run vim.exe, not gvim.exe.
Add this to the Path under system variables "C:\Program Files\Vim\vim82" . Then you are all done.
To Edit Environment Variables:
Click on Start Menu -> Type Environment Variables and Press Enter Supporting Image -> In bottom Right Corner you will find "Environment Variables" Supporting Image -> Under System Variables Search for Path Supporting Image -> Double Click To Edit -> Click on new and Paste the file address given AboveSupporting Image
Now you're done. Test it just by writing vim in Command Prompt or Windows Terminal.

Eclipse doesn't use the path set in .bashrc

whenever I run eclipse from the shortcut I am unable to correctly build some of my projects because the PATH variable that I configured in .bashrc doesn't get used.
When I run eclipse from my terminal, I can build all my projects perfectly fine because it's running through the correct shell.
The problem is that I want to use the PATH variable from my .bashrc without permanently having a terminal open. I tried this before, but every day I accidentally close the terminal that's running eclipse by accident and lose all my unsaved code.
Can anyone help me?
Your tooling probably utilizes the embedded eclipse terminal. This terminal does not start providing your login/user shell. So you need to set the eclipse terminal in your Eclipse preferences to start as --login shell:
Go to:
Preferences -> Terminal -> Local Terminal
and set
"Arguments" to "--login"
restart Eclipse and your users $PATH should be used from now on.
Edit /usr/share/applications/eclipse.desktop with write privileges, i.e. sudo gedit /usr/share/applications/eclipse.desktop
Change the setting Exec=/usr/bin/eclipse to Exec=bash -ic "/usr/bin/eclipse" and save
The underlying issue is that .bashrc is not loaded in a non-interactive shell. When you start Eclipse normally clicking on its symbol, .bashrc quits early. This solution applies to all programs that are defined by a .desktop file.
In contrast, bash -i opens an interactive shell, -c "" runs a command in that shell.
I can think of two options for this problem:
write a small script, export those vars or source your .bashrc before you start your eclipse.
define those variables in /etc/environment. then they are not user-scope any more.
I prefer the 1st option.
Create simple script
#!/bin/bash
source /home/user/.environment_variables
/home/user/eclipse_cpp/eclipse -Duser.name="My Name"
2.
Next put your all system variables in file /home/user/.environment_variables (any file you want)
My looks like:
export COCOS_ROOT=/home/user/Projects/edukoala
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
3.
Now you can delete your variables in .bashrc and put line
source /home/user/.environment_variables
Everything works fine :)
Well, this is already answered and the answer has been accepted. But this will also work for running your code using Eclipse. You can edit the Run Configurations and set the environment variable there. Then, Eclipse will pick up the variable from this setting while building.

getting vi and rxvt to work in cygwin

I am trying to use rxvt on my cygwin w win XP but the terminal appears and disappears. What could be wrong? This is true for all except rxvt-native . I have tried a few commands found online but with no success. I include 2 I have tried:
start C:\cygwin\bin\rxvt.exe -sb -sl 3000 -fg gray -bg black -fn "Lucida Console-14" -e /bin/bash --login -i
.
path C:\cygwin\bin;%path%
ssh-agent rxvt -e bash --login -i
Another problem I am facing is trying to get vi to work in my cygwin bash shell. Setting term to xterm or vt100 does not work. Hitting enter, I see a string 78 or some other issue pops up. I have never modified my .inputrc.
My main issue was trying to get vi to work properly. I just found out that if I run
/etc/postinstall/terminfo.sh.done , I can now navigate properly in vi. The 78 (newline) M still appears but at least I can navigate in vi.
Feb 25 - This problem went away after a few windows updates. Would it make sense to ANSWER my question on the basis that this is longer reproducible?
Can't answer the first question, but have you tried invoking rxvt from its shortcut in the Cygwin folder of the start menu?
Regarding the second question, the TERM variable tells applications what terminal they're running in, so if you set it to 'xterm' while running in the Cygwin console (where normally TERM=cygwin), they'll be sending xterm control sequences that the Cygwin console doesn't understand. So basically: don't do that!
Btw, you might also be interested in Cygwin's mintty package, which is another terminal that doesn't need an X server. Installing it also creates a start menu shortcut in the Cygwin folder.
I would assume you need an X server running.
You could install Cygwin/X
One thing which may not have been clear was that the whole exercise was to get vi to work. vim did not work either at that time. But after some windows update, the problem went away. Closing it...

Resources