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

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.

Related

Changing shell from /bin/bash to /bin/zsh disappears programming tools?

I became very interested in Linux and wanted to customize my terminal with ZSH and powerlevel10k, but after changing and logging out, the programming tools disappears. I tried very hard to understand the reason but it did not work. I am not very familiar with the $PATH command and I do not know if it works or not. Thanks for your help.
image link => https://i.stack.imgur.com/BLeLe.jpg
Changing default shell to ZSH can help
first find the path of your ZSh shell.
type -a zsh
then change it
chsh -s /bin/zsh
now log out and log in again. One can close the Terminal app and reopen it.
After digging, I finally realized that the files that were installed with SNAP are not displayed. When I installed the file in Deb format, it became known.

Linux xfce desktop launcher: Run a nested command

With xfce4-terminal (on Manjaro): Running chromium "$(xclip -o)" will open the Chromium web browser and visit the content of the clipboard (which is assumed to be a single URL).
I want a desktop launcher to do exactly this. Creating a new launcher (right click on the desktop > create launcher) with the above command in the command field won't work: Chromium is opened, but the address bar says %24%28xclip%20-o%29.
What is happening? The tiny bit of bash knowledge I have tells me that I need to escape some characters -- which ones? I tried different things like chromium \"$(xclip -o)\" and chromium "\$\(xclip -o\)", which produce similar outcomes, but I can't figure it out.
I found this specification of launcher items, but I seemingly fail to understand it well enough to apply it to my problem. Or am I completely on the wrong track?
Another application would be this: xfce4-screenshooter -f -s "$(date +screenshot_%Y-%m-%d_%T.png)" takes a screenshot and names the resulting file with a time stamp. It works being directly run in the terminal, but not when configured as an application shortcut in the keyboard settings. Analogously, the file is named $(date +screenshot_%Y-%d_%m-%T.png).
Try:
bash -c "chromium $(xclip -o)"
in your command field. That worked for me at least. (Also using Manjaro XFCE)

Run gnome-terminal from tty

How can I run gnome-terminal from tty1?
I tried setting $DISPLAY variable to :0, but still nothing and gnome-terminal doesn't appear in the X window system.
However, xterm and firefox, work fine from tty1.
What am I missing?
What do you mean by tty1?
Did you run xstart when you were on tty1 and got a GUI where you expect everything to run?
It is possible that gnome-terminal expect some familiar desktop environment but crash due to lack of one. It is possible that you will need to specify the Xorg display with --display=DISPLAY option even if there is only one display.
Run gnome-terminal --help-all and read the output for more info.
Sorry for asking you questions in answer section but I apparently don't have enough reputation to add a comment.

Screen and Cygwin: no tab completion?

I'm having some problems working with my development environment. Specifically, after I invoke the screen utility from within Cygwin I lose the ability to do tab completion. Before I invoke screen however tab completion works just fine.
I messed around with setting different values for the TERM env variable (VT100, xterm etc) but without success. It must be something trivial but I have no idea anymore. Does StackOverflow have any suggestions for me?
when you issue 'screen' from inside cygwin it might put you in another shell like /bin/sh instead of /bin/bash (and bash is where you're getting the tab completion from).
To fix the problem you could edit your .screenrc file (found in your home directory) and add in this line:
shell bash
Then try running screen again and you should see tab completion work within this new window.
The problem is that bash needs to be run as a login shell in order to have tab completion in the default cygwin setup. If you run bash in a cygwin bash you won’t have tab completion either. To set screen to run bash in login mode, add this line to your ~/.screenrc file:
shell -bash
I had a similar problem with git autocompletion not working when using screen on a linux machine, but wasn't due to a different shell. I fixed it using this question: Git autocomplete in screen on mac os and doing the following:
Get the git autocompletion script
curl https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -OL
why would you want that hanging around?
mv git-completion.bash .git-completion.bash
add this line to your ./bashrc
source ~/.git-completion.bash
Then in your terminal
source ~/.bashrc
That worked for me.
(I imagine after three years you've probably solved your problem, but I hope this helps someone else)

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