Which project provides the terminal emulator used by the bash from Git for Windows? - cygwin

I am having a problem* with the bash that comes with Git for Windows.
But I don't even know where to start looking/googling/reporting the bug.
It seems that all of MINGGW64 (= MinGW-w64?), MSYS, Cygwin and maybe Mintty are somehow involved, but I don't really understand the relationships between them.
Which one is providing the terminal?
* It ignores the VT100 escape sequence sent by echo -e '\033[?1h' which should put the cursor keys in "application mode" (= make them send <ESC>OA instead of <ESC>[A).

I assume you have already found, if not
https://mintty.github.io/

Related

How to enable 'gx' in Vim? Mine doesn't work anymore

I have tried wiping my .vimrc, uninstalling all plugins, updating Vim, trying different shells, etc. but I absolutely can't get 'gx' to work over a given URL. I have used it before and it worked fine, it even use to open up my finder directory if I 'gx'ed on a blank line. I tried running 'gx' over numerous URLs, above them, below them, adding "/" at the end, etc. Still no luck. I am simply at my wits end trying to figure out why it no longer works when it use to. Sometimes it will open a URL in a blank buffer with the buffer name equal to the URL and other times nothing happens. I would be grateful to anyone who actually knew what the hell is going on with this stupid thing.
I am on the latest version of OS X and have the latest version of Vim.
UPDATE
I found the answer to this question but still am not quite sure why it worked and my original approach didn't.
Original Approach
I installed iTerm2 and was forced to set Preferences >Profiles >General >Command >Command >/usr/local/bin/zsh -l. Even though I ran $ chsh -s /usr/local/bin/zsh and added /usr/local/bin/zsh to /etc/shells, I could not get >Profiles >General >Command >Login (radio button) to work.
I would either get an error message in Terminal or the window would simply flash and disappear in iTerm. However, running my profile command /usr/local/bin/zsh -l in my mind should have forced the shell to run in login mode (the same mode as my default) but it caused major issues in vim where I couldn't get any shell command or function that relied on shell commands to work (e.g :!ls, gx).
ANSWER
Moreover, I finally managed to get everything working perfectly after running chsh -s /bin/bash (e.g. back to its default). Suddenly, I was able to run both Terminal and iTerm with the radio button for Login checked and all my issues went away. It should be noted that I tried to chsh -s /usr/local/bin/zsh and received an error that I didn't receive the first time--something about a non-standard login shell.
This wasn't good enough though because I really wanted to use my Homebrew zsh (and bash) shells since they are more current. Finally, I found the answer, I ran sudo dscl . change /users/$USER UserShell /bin/bash /opt/local/bin/zsh and I was then able to leave the Login radio button checked and actually use -zsh for the first time without any issues.
NOW MORE QUESTIONS
My questions now are: 1.) Why didn't my original profile command, /usr/local/bin/zsh -l work as though it was my default Login shell? Aren't they the same (e.g. a login shell is a login shell)? 2.) If I update /etc/shells with /usr/local/bin/zsh why would I receive a "non-standard shell error"? 3.) I read the MAN page on dscl but don't understand how that actually changed my Login shell when chsh -s /new/shell/path didn't work? 4.) Does ANYBODY really know what the heck is going on here?!
If you are a moderator please let me know if I should break these questions up into different posts but this is sort of a big issue and I can't believe I am the only one who has had this problem as I couldn't find ANY Q & As that thoroughly explained what is going on. Thank you all in advance for your help!
I'm on OS X and running the following command in vim worked for me:
:let g:netrw_browser_viewer='open'
See also this similar answer for Fedora:
:let g:netrw_browsex_viewer="setsid xdg-open"
I had the exact same problem, and it ended-up getting resolved (+quite a few bonuses) from this small but effective plugin:
https://github.com/stsewd/gx-extended.vim
Adds support for partial URLs, markdown URLs, 'Plugin' -> github paths, etc. It is much better behaved than netrw.

Why does my shell prompt disappear when I install vim 7.4?

I'm using CentOS 6. Since the CentOS repos have an older version of vim (7.2), I have compiled my own. However, I am having a weird issue. After running and exiting vim, I've found that my shell prompt has disappeared. Also, when I type, it does not appear in the terminal, nor does any output. What's weird is that it looks as though something is being outputted, since the cursor will move down the screen, but I can't see anything.
It must have something to do with compiling an X version, because it does not happen when I compile vim without X windows support (but I would like to have gvim, too). Here are the configuration options I supplied when compiling:
./configure --prefix=$OPT/Cellar/vim/7.4 --with-features=huge --enable-gui=auto --with-x --enable-xim
I also tried compiling without Xim. I've also tried explicitly setting --enable-gui=gtk2 (which is what gvim 7.2 from the CentOS repos uses).
I am using KDE4. The problem occurs both when running tcsh and bash. I have tried with $TERM set to both xterm and xterm-256color as well.
Additionally, running neither reset nor stty sane restores the shell to its proper behavior.
Any idea why my prompt disappears when running vim? As I missing a config flag or some other compilation issue?
I ultimately traced this down to an error in my ~/.vimrc file. I had some lines like this:
if has('gui_running')
# Gvim customization
endif
if has('gui_gtk2')
# GTK2-specific Gvim customization
endif
The second block was running every time vim loaded. Because it changed some window geometry, it ended up messing up bash; when I dropped back to bash, bash thought it only had ~53 columns to work with (and possibly some other things were messed up).
Solution: The second if block should be inside the first.

Terminal does not seem to have reverse-i-search (ctrl-r does nothing)

I'm ssh-ing into a remote machine and when I try to search my history in a linux terminal with reverse-i-search, nothing happens. I press ctrl-r as I usually do on my machine, but the prompt doesn't appear.
Any ideas? How can I check the keybindings for ctrl-r? How do I set them if they aren't set? Do I have to apt-get reverse-i-search functionality?
Thanks!
To use ctrl-r your shell needs to be using readline (or something similar), your history should be collected.
So you should verify your shell for example sh doesn't support this.
You should check it the history is collected. For example with bash shell: echo $HISTFILE
I think these can be the main reasons.
Hopefully with simply entering bash, you can switch to a proper shell which will support this.

Running gvim from MSYS --- how to avoid/change MSYS enviroment variables?

When I run gvim from MSYS, things go wrong during initialization. Namely, gvim can't find the initialization files that are in 'C:\Documents and Settings\username\vimfiles.
[Specifically, gvim reports the error E117: Unknown function: pathogen#infect during initialization, so it never found autoload\pathogen.vim. Doing :scriptnames also confirms that none of the setup files from vimfiles\ are run.]
I think I've debugged why it goes wrong. When you start MSYS, the MSYS shell inherits the windows enviroment variables, but changes some of them to it's custom values. C:\Documents and Settings\username is the value of $HOME in Windows, but MSYS sets it to something like C:/msys/user name. And of course, Vim uses $HOME to find the right initialization files.
I also notice set shell? has changed to something like shell=C:/msys/bin/sh instead of shell=C:\WINDOWS\system32\cmd.exe, but I hope this isn't important for fixing the initialization problem.
I need to run gvim with the normal windows environment variables. At least I need to be able to manually override a few important ones like $HOME to something I specify (i.e., I'm not concerned about my windows $HOME changing, so it's fine to use a static value).
I tried to reset $HOME manually in my vimrc, but by then it is too late.
Is there some trick to specifying $HOME early on during initialization, or as an extra command line parameter?
Alternatively, is there some trick with running commands from msys differently? I know almost nothing about how the shell C:/msys/bin/sh works, but I could conceive of some extra arguments that changes the visibile environment for the command (e.g. gvim.exe) you are typing.
---Edit---
Reposting the solution that worked (it achieves the later idea):
Instead of running gvim.exe, run the command HOME="C:\Documents and Settings\username" gvim.exe
In bash and other UNIX shells, you can do:
$ HOME='/path/to/dir' gvim
to temporarily set $HOME to a different value.
I admit I'm not familiar at all with the Windows command line, but it might be worth a try.
I believe you can define $HOME just like any other environment variable.
Try adding this to the start of your .vimrc.
let $HOME="C:\Documents and Settings\username"
I had a similar issue when running Cygwin (which is similar to MSYS).
The easiest solution for me was to simply set the HOME environment variable to an empty string. Otherwise, the Cygwin HOME value would be appended to the Windows USERPROFILE in GVim and it would fail to start correctly. Not explicitly setting the full path of the HOME means that I can use the same start-up files on different systems where the USERNAME may not be the same.
Likewise, the SHELL environment variable should not be inherited from Cygwin Bash. This results in errors when running shell or external programs via !. Again, I set this to be an empty variable since Vim is smart enough to figure out what it should be.
In my .bashrc, I set the following alias for running Windows gvim which starts GVim with the HOME and SHELL variables set to an empty string – just for that command.
gvim="/cygdrive/c/Program Files (x86)/Vim/vim74/gvim"
if [ -x "$gvim" ]; then
alias gvim="HOME= SHELL= \"$gvim\""
fi
unset gvim
I achieved this by making a windows symbol link (Win 7 or higher).
Via a symbol link, you can even make vim and gvim to use the same configuration and plugin.

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