After following this comment I added all my startup/alias commands to ~/.bashrc file and in ~/.bash_profile I added source ~/.bashrc

But still my aliases are not working. I have to manually source ~/.bash_profile overtime (with source ~/.bash_profile).

My .bashrc file:

alias km='cd /Users/apple/Desktop/km'

and my .bash_profile file

if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
source ~/.bashrc

In my user directory I only have following files: enter image description here

My iterm2 profile: enter image description here

UPDATE: For me this solution actually worked

  • is your terminal configured to launch a login shell? – glenn jackman Dec 29 '15 at 18:15
  • Yes I guess its using login shell. Please check screenshot attached above – Niraj Chauhan Dec 30 '15 at 4:57
  • Try running Terminal, the built in one not iTerm. Does it load your alias? – Arc676 Dec 30 '15 at 10:00
  • no it didnt work :( – Niraj Chauhan Dec 30 '15 at 11:13
  • If you solved your problem, please post an answer and accept it. Make sure you include proper acknowledgement of the original author, a link, and the most important information from said post. This helps future users by allowing them to easily see that the problem is solved even if they miss the last line. – Arc676 Jan 2 '16 at 7:50

So after all struggle the only solution which worked for me is by executing source ~/.bashrc every time when I open my terminal.

| improve this answer | |

I've gotten it to work by using .login and .profile. The way it works is .login is sourced by every login shell and it in turn sources .profile

In .login I have:

. .profile

and in .profile I have:

function pgrep(){
ps -axww | grep -i "$1" | grep -v "[p ]grep"

function diskspc(){
sudo find / -iname "*$1*" -print0 | xargs -0 du -chs

export JAVA_HOME

alias rsync="rsync --stats --progress"

alias forcequit="open -a iForce\ Quit"

alias ls="/bin/ls -FG"
alias ll="ls -la"
alias gls="gls --color=auto -aF"

alias find="/usr/bin/find"

. /sw/bin/init.sh

export LC_ALL

alias locate2='if [ $((`date +%s`-`eval $(stat -s /var/db/locate.database); echo $st_mtime`)) -gt 3600 ]; then echo "locate: db is too old!">/dev/stderr; sudo /usr/libexec/locate.updatedb; fi; locate -i'

alias flocate="/sw/bin/locate.fink --database=/sw/var/locatedb"


#export LESS_IS_MORE

Of course,feel free to use or not the stuff in my .profile.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .