gvim reads _vimrc, vim does not - windows

I'm running vim from an external hard drive, so _vimrc is not in %HOMEPATH% the way it normally is.
_vimrc is inside the vim folder, in addition to the vim73 and vimfiles folders.
_vimrc works when I run gvim, but not when I run vim.
Why?

If you are using MSYS or Cygwin, these programs will cause vim to look for your _vimrc in their own home directories, not the typical Windows home directory.
If this is the case, you can probably fix it by making a link to your _vimrc and placing it in their special home directory.

Seems you are using vim on Windows, if you are using vim binary release with GVIM, it should work without problem, just confirm it by checking your path command "path", and make sure you had installed vim with command line script, it's a option during installation.
If you are using MSYS or Cygwin, just type "type vim" to see which vim binary you are using, and check your home by 'cd ~', it should use the rc file under ~ unless you had some customization with previous binary/shell script.

Related

Is it possible to use fzf (command line fuzzy finder) with windows 10 git-bash?

I downloaded the .exe file and placed it into my PATH variable. fzf seems to work in command prompt. But I would like to use it in git-bash. When i use fzf in git-bash it seems to start but nothing happens.
Any advice would be helpful. I'm trying to save myself some keystrokes.
Yes it is.
I just downloaded fzf.exe from fzf-bin, launched bash.exe, and typed ./fzf.exe
But for that, I use a simplified PATH first:
set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%GH%\mingw64\libexec\git-core;%PATH%
With that PATH, fzf just works.
I know this question was a while ago, but hopefully I can be of some use for any new readers trying to get fuzzy finder working, in git-bash
For whatever reason, I had tried the package from the GitHub repo #VonC shared and the new repo linked thereof and neither package executed in terminal as expected - Only thing could do was fzf --help
As you know git-bash is based on MSYS2, and they have pacman to install packages and a package list can also be found here https://packages.msys2.org/package/ including a fuzzy finder, however not fzf, but fzy
To get the Windows compatible file, go straight to 'File', not the upstream URL and within the downloaded compressed file you will find the .exe
Move that .exe to your git-bash /usr/bin and either rename fzy.exe to fzf.exe or bash alias fzf to execute fzy

Opening Sublime Text from Bash on WSL

I have done
alias subl='"/mnt/c/Program Files/Sublime Text 3/subl.exe"'
However, doing subl test.txt will now open Sublime text in C:/System32/test.txt, which doesn't exist and thus I can't save it. Nor do I want to save something to System32. How can I change it so that my actual files are opened?
Also, if I do subl ~/test.txt then it tries to open C:\home\<myname>\test.
The first answer is good, but won't work if your linux fs is linking to a windows folder (i.e. /home/me/something -> /mnt/c/something - subl ~/something/file will fail), nor will it if trying to access the windows fs directly (i.e. subl /mnt/d/file).
Here's a more complete script I just wrote starting from the above answers, that will open files in sublime both on Windows or Linux paths.
https://github.com/grigger/subl-wsl
I know it's quite a while after the answer, but maybe some other folks will be helped by this in the future.
You can write a script that opens subl in the correct location and put it in your Linux PATH(e.g. in /bin).
That script opens subl.exe at the right location. For WSL1 the script could look like that:
#!/bin/bash
/mnt/c/Program\ Files/Sublime\ Text\ 3/subl.exe "C:/Users/<Username>/AppData/Local/Packages/<WSL Distro name>/LocalState/rootfs/$*"
WSL is like a Linux virtual machine for windows.
So you have to install sublime Text for Linux on WSL.
see here

Windows cmd git bash: conda.sh no such file or directory (Windows line endings, missing slashes)

I'm working in Windows 10 with a fresh installation of Anaconda and Git Bash. I decided to set cmd.exe as my default console program to use git bash (instead of the minTTY), and I think already I am getting issues with Unix style characters vs Windows.
When I fire up cmd Bash tells me it can't find my conda.sh file:
bash: C:UsersjoshuAnaconda3/etc/profile.d/conda.sh: No such file or directory
First, it looks like bash is missing the default windows slashes for my root directory ("C:/Users/joshu/"). Does anyone know how to fix this?
Thanks
I have the exact same problem. Run ~/.bashrc in a terminal. Go to the path given and correct the conda.sh path.
In your case, you will replace the C:\Users\joshu\Anaconda3/etc/profile.d/conda.sh to C:/Users/joshu/Anaconda3/etc/profile.d/conda.sh
Your only problem is that your slashes are set wrong.
Fix this issue by opening ~/.bashrc and change location of conda.sh, e.g. in my case
. D:/Users/my_user/ProgramFile/Continuum/anaconda3/etc/profile.d/conda.sh
Had the same problem on Windows 10/Git Bash/Anaconda installation. If you run ~/.bashrc in Git Bash, it should give you the location of the shell script file containing the incorrect path. Once you correct the path in that file, the message should disappear when you restart the terminal.
Another thing to check is make sure your user profile folder under C:\Users has not gone hidden. If it has gone hidden, then the C:\Anaconda\etc\profile.d\conda.sh script
won't be able to find the folder.

Shell (Bash) - Can I have fully portable .bash_profile / .bashrc / .bash_history files?

Background
I'm a Front End Web Developer that has started moving to PortableApps where I can; at least for the desktop machines I use (Windows) after building a machine and having to re-install Windows multiple times.
It's getting more and more important to use the command line with build automation tools, testing software with a CLI etc.
I have just got portable versions of Git (Bash) and ConEmu working from my Dropbox (but ideally this would work from USB too). This means I have access to a Unix shell on Windows with Git, but the .bash_profile (and .bashrc) I have saved I need to manually copy to the '~' (home) directory for each machine I use.
Question
Is there a way to link my portable console with bash files not located in the home directory of the user on each machine used?
For instance when my console opens and looks for these files, can I ask it to check a different directory without setting any config on each machine? And then get the .bash_history to save here too instead?
You can use symbolic links for .bash_profile and .bashrc:
ln -s /path/to/.bashrc ~/.bashrc
ln -s /path/to/.bash_profile ~/.bash_profile
And inside your .bashrc you can define where your history file is located:
export HISTFILE=/path/to/.bash_history
I don't think there's any way around having .bashrc and .bash_profile in your home directory. Unless you start bash with the --rcfile option:
bash --rcfile /path/to/.bashrc
There is also the system wide file located at /etc/bashrc.

How to make babun/cygwin home directory equal windows home directory?

I just installed babun, a variant of Cygwin. I want the cygwin user home directory to equal my windows home directory.
So, to be clear, I don't want to add the cygwin home to the C:\Users as a new user, I want it to be the same as my current windows home directory.
Now, according to this post, How can I change my Cygwin home folder after installation?, there is a neat way to make the cygwin home directory point to your windows home directory.
You open the file /etc/nsswitch.conf and make sure is has a line db_home: windows. However, after restarting my pc, echo $HOME still says /home/chiel.tenbrinke, which is not what is should be. It should say something like /cygdrive/c/Users/Chiel.tenBrinke.
Why is this not working?
My cygwin version is CYGWIN_NT-6.1-WOW IM-Chiel-2015 1.7.35(0.287/5/3) 2015-03-04 12:07 i686 Cygwin.
Babun has a surprisingly good FAQ. The last entry in the FAQ is How to Use the Windows home directory as Babun's home directory?
For me, it boiled down to:
Create an env var for $HOME = /Users/my_account_name via Win+R sysdm.cpl
Run mkpasswd -l -p "$(cygpath -H)" > /etc/passwd
Run babun install
I'm not sure why Babun doesn't recognize the standard cygwin setting in /etc/nsswitch.conf, and I'm a bit surprised there was no mention of this setting in the Cygwin FAQ. I'm a bit concerned that in spite of what a great collection Babun is, it may fall out of sync with Cygwin quickly if not properly maintained.
I tried an easier way and works perfectly so far.
Just mv your home folder to the location you want, and make a symlink
The first execution after move may prompt errors, run babun install will fix everything.
in /etc/nsswitch.conf
db_home: /cygdrive/c/Users/%H

Resources