Cmder: .bash_profile equivalent?

Created on 9 Jan 2014  路  6Comments  路  Source: cmderdev/cmder

MSysGit will read your ~/.bash_profile file and load various functions and aliases from it. Is there any way for Cmder to have this feature since it uses MSysGit?

Most helpful comment

There's now a config/user-startup.cmd file created for this purpose as well as the already available powershell $profile areas to use. Should be available from the 1.3 release onwards.

All 6 comments

  1. What would you suggest to add? We currently have windows native aliases.
  2. Can you provide relevant docs from msysgit?

Thanks

.bash_profile allows you to create bash functions that can be called directly from the CLI. The key advantage of functions is that they can accept parameters.

For work, I often SSH into a set of specific servers. To make it easier, I create a single function called "s" that accepts a server name as an argument. The body of the function is a switch statement that maps the server name I passed in to an IP address or domain.

I can't seem to find any docs from MSysGit. I would imagine it is a straight copy from the bash implementation found here. .bash_profile is essentially just a file that gets run when the terminal starts. You may be able to just emulate the feature by running some file within the cmder directory.

Here is an easy way to demonstrate the feature.

  1. Open MSysGit (Git Bash)
  2. $ printf "function foo\n{\necho \"Hello, \$1\"\n}\n" > ~/.bash_profile
  3. Restart MSysGit
  4. $ foo world

I think there is nothing like that for cmd.exe + msysgit.
But
I think it would be nice to also add git bash to cmder. So I will add that to the todo!

@Knotix As a workaround, I edited my init.bat to launch bash, which launched the MSysGit bash and have a .bash_profile in my home directory, which is picked up by MSysGit bash

@Knotix My workaround for this was to add the following lines to /vendor/msysgit/etc/profile

if [ -e $CMDER_ROOT/config/.bash_aliases ]; then
    . $CMDER_ROOT/config/.bash_aliases
fi

Then place all of my desired aliases in /config/.bash_aliases.

There's now a config/user-startup.cmd file created for this purpose as well as the already available powershell $profile areas to use. Should be available from the 1.3 release onwards.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AaronKaa picture AaronKaa  路  3Comments

danwellman picture danwellman  路  3Comments

emesx picture emesx  路  3Comments

sathishsoundharajan picture sathishsoundharajan  路  3Comments

jordanrobinson picture jordanrobinson  路  3Comments