Can I specify a path in git whose name depends on the operating system

I want to save Mac, Windows and Linux vim configuration files in git. On * nix systems, your vim configuration files are included in $ {HOME} /. Vim, but for Windows binary, the same directory is called "vimfiles". Can I configure git to host the name of another directory?

+6
source share
3 answers

My setup is very simple.

On Mac, the catalog version is:

/Users/username/.vim 

On Linux, this is:

 /home/username/.vim 

On Windows XP (yes), this:

 C:\Documents and Settings\username\vimfiles 

They all point to the same GitHub repository.

My settings are stored in a vimrc file (no . Or _ ) located in the root of the repository. Thus, its version and command / push / pull, like everyone else.

Actual user vimrc ,

 /Users/username/.vimrc /home/username/.vimrc C:\Documents and Settings\username\_vimrc 

is a real file, without a symbolic link. It contains only one line:

 runtime vimrc 

which tells vim to read and execute my vimrc .

Due to how :runtime works, I don't need to use a real absolute path, which will be different on Unix-like platforms and on Windows.

Setting up a new computer or user is as simple as cloning my repo and entering two easy-to-remember words.

+2
source

You do not need to configure Git, just ask Vim to use ~/.vim for Windows by adding the following snippet to your ~/.vimrc :

 " On Windows, also use '.vim' instead of 'vimfiles'; this makes synchronization " across (heterogeneous) systems easier. if has('win32') || has('win64') set runtimepath=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after endif 
+6
source

I also need to exchange configuration files for vim and other applications between several systems, and I found that git was not only excessive, but also required manual synchronization on each system in order to receive the latest updates and post changes. The best solution for me is to put these configuration files in Dropbox, make all my systems connected to my Dropbox account, and create symbolic links to these shared files.

For example, I placed the vimrc file under Dropbox/conf/vimrc and then did

 ln -s ~/Dropbox/conf/vimrc ~/.vimrc 

You should be able to use Windows' mklink for a similar effect to create a _vimrc symbolic link to the same file. In the same way, the Dropbox/conf/vim shared directory can be linked locally as .vim or .vimfiles or whatever your preferred vim executable is.

Dropbox keeps a history of changes over the past 30 days, which is enough to handle recovering most of the problems for which I need git. The best part is that you can add this new macro or setting to your .vimrc , and it will be automatically available for all your systems.

Of course, this approach is also convenient for your other configuration files ( .gitconfig , .gitignore , .bashrc , etc.).

+1
source

Source: https://habr.com/ru/post/920947/


All Articles