How to create an alias for git bash to quickly create cd through directories

I use git bash and I will say that I have 2 folders: C: / folder1 and C: / folder2, I would like to make a quick cd from one to the other.

I tried git.alias, but it seems to work only for the "git ..." commands. And I'm not very familiar with all this bash stuff .. so how do I do this?

+6
source share
4 answers

In bash, you can do the following to create an alias:

alias cdf1="cd /user/home/cloudera" cd /user cdf1 pwd 

You will get the result pwd as / user / home / cloudera. You can do the same at the git - bash prompt, as well as the directory "C: / folder1" instead of "/ user / home / cloudera".

+10
source

The following are aliases for Git Bash on Windows (MSYS Git)

I finally managed to get alias for Git Bash by putting the .bash_profile file in the Windows user's home directory ( %USERPROFILE% , usually C:\Users\<username>\ ) and adding the following to it (example):

 alias cdf1="d/Folder/Another\ folder\ with\ spaces/Destination/" 
+4
source

Windows users can create a .bashrc in their users folder and set aliases there:

alias folder1='cd /c/folder1'

+1
source

You can simply define child aliases:

 doskey cdf1=cd c:\folder1 doskey cdf2=cd c:\folder2 

Then a simple cdf1 will bring you to the right folder, even in a git-cmd session.
In a git - bash session , you need a bash alias, but you don't need a bash session to use git.

0
source

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


All Articles