0

Before I dove into learning ruby my .vimrc file had this at the very end

cd data

It was perfect because the home directory is shared with my mac. I tried changing my home directory in OSX. This was a nightmare, and not what I was looking for.

I see tons of answers on how to change home directory. This unfortunately will make the change for more than just terminal/vim

I've been playing with

x = pwd
if (x == '/users/jack/)
    cd data

The above is in my .vimrc file, it also doesn't work. Until now the only place vim would start is in the default location. Now that I've been installing ruby gems I've been receiving problems.

Is there an easy way for vim and terminal to open at /users/jack/data rather than /users/jack?

Any solutions that address my issue are win32 solutions. Changing my home folder on my mac is going to move things I don't want into my data folder.

Thank you.

2 Answers 2

1

I agree with romainl's answer, but to directly answer your question, try this:

if getcwd() == $HOME
    cd data
endif
0

I have a hard time imagining a good reason for changing the location of your $HOME directory or even why you'd think it could work without issues.

If you want to open Vim in a specific directory, cd to that directory first and start Vim from there.

If that's still too much work, use an alias that does that for you.

If you want your terminal to start in a specific directory, append something like cd /path/to/directory to your ~/.bashrc or ~/.profile. You can set Terminal.app and iTerm.app up to start in a specific directory as well.

1
  • I had already added cd /path/to/directory in my .zshrc/.vimrc file. The problem was when vim/iterm was opened from a location that wasn't my home file. Which happened when I installed gems.
    – Ravenous
    Jul 1, 2014 at 13:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .