Question

I have a symbolic link('cur_project') in my HOME directory and want to change its destination every time i start working on any new project by just calling the SET_CUR_PROJ variable on terminal.

I've added a line in ~/.vimrc file like this:

SET_CUR_PROJ= "ln -sf -T $PWD $HOME/cur_project"

By this line i mean that whenever i call this variable it should change that symbolic to current working directory. I am running this command as :

$source ~/.bashrc
$$SET_CUR_PROJ

Problem with this approach is it resolves the two variables $PWD and $HOME at the time of source but i need to resolve $PWD into its recent values.

Was it helpful?

Solution

variables don't work like that. What you want is a function:

function SET_CUR_PROJ {
    ln -sf -T $PWD $HOME/cur_project
}

Then you invoke it with SET_CUR_PROJ

OTHER TIPS

Or - at the cost of invoking another process - you can do $(pwd).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top