Alias defined in .bash_profile not working in OS X

后端 未结 2 1210
滥情空心
滥情空心 2021-01-13 08:19

I have defined three aliases in my .bash_profile but my bash shell is not reading it. The aliases defined are not working in my terminal and I couldn\'t resolve

2条回答
  •  情话喂你
    2021-01-13 09:07

    We still don't know why aliases are not loaded automatically.

    Your aliases should be loaded from the .bash_profile. This is the default behaviour of bash in OS X.

    mklement0 wrote more about the problem in their answer in this thread.

    A hacky workaround

    Open the Preferences of the Terminal. You specify the command you start your shell with:

    Instead of manually sourcing your dotfiles every time you can specify which file you want to source when the shell opens. Here is the list of options for bash:

    Usage:  bash [GNU long option] [option] ...
        bash [GNU long option] [option] script-file ...
    GNU long options:
        --debug
        --debugger
        --dump-po-strings
        --dump-strings
        --help
        --init-file
        --login
        --noediting
        --noprofile
        --norc
        --posix
        --protected
        --rcfile
        --restricted
        --verbose
        --version
        --wordexp
    Shell options:
        -irsD or -c command or -O shopt_option      (invocation only)
        -abefhkmnptuvxBCHP or -o option
    

    You might consider using /bin/bash --rcfile alias_file_of_yours or something similar.

    Go for goat if you need aliases using the cd command.

    As a side note I do recommend you to check out goat. It lets you manage such cd aliases easily.

    I use it and I wrote it.

提交回复
热议问题