An alias defined in .bash_profile that does not work on OS X

I defined three aliases in mine .bash_profile, but my bash shell does not read. Certain aliases do not work in my terminal, and I could not solve this problem.

alias handybook="cd /Users/rsukla/development/repos/handybook/"

This line is defined internally .bash_profile, but it does not work in my shell.

Things I've tried so far:

  • I created a file .bashrcand defined an alias, but it also does not work.

  • if I used source ~rsukla/.bash_profile, then the alias works fine, but I want the alias to be constant, so I don't need to use it sourceevery time I open my shell

Any idea why hell aliasdoesn't work when I spot in .bash_profile?

+4
source share
2 answers

We still do not know why aliases do not load automatically.

Your aliases must be loaded from .bash_profile. This is the default bash behavior in OS X.

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

Hacker workaround

Open the terminal settings . You specify the command with which you start your shell:

terminal preferences

Instead of manually receiving your point files every time, you can specify which file you want to use when opening the shell. Here is a 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 can use /bin/bash --rcfile alias_file_of_yoursor something like that.

goat cd.

. cd.

, .

+1

, :

  • OS X, Terminal.app iTerm2
  • bash ( OS X)

~/.bash_profile , .
Bash ~/.bash_profile, ~/.bashrc.

, Linux, , - , ~/.bashrc, ~/.bash_profile.
, , , ~/.bashrc, ~/.bash_profile, :
[[ -f ~/.bashrc ]] && . ~/.bashrc


, bash -l ; , , / .

  • echo $SHELL , .
  • Terminal.app, Terminal > Preferences..., tab General, Shells open with , .
+3

All Articles