In Ubuntu I like having
shopt -s autocd
in my .bashrc file for automatic CD'ing with typing 'cd', i.e. just type the directory name (and probably use tab completion too) and press return and be cd'd to the directory if it exists.
On OSX this isn't valid in my .bashrc
How can I do a 'depends on' for this? So that I can share and maintain just one .bashrc between the two OS's ?
I know for a file I can do stuff like:
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
and for an application like tmux that depends on screen I can do
if [[ ! $TERM =~ screen ]]; then
if [ -n "$(type -P tmux)" ]; then
exec tmux
fi
fi
but I can I do this kinda thing for whether I can do shopt -s autocd ?
uname -smight be enough. – Mat Apr 12 '14 at 18:34[[ $(uname) -eq Linux ]] && shopt -s autocdas I suggested below? – terdon Apr 12 '14 at 19:18$ [[ $(uname) -eq dsdss ]] && echo 'y'returned 'y' – Michael Durrant Apr 12 '14 at 19:24-eqdoes integer comparison, not string.[[ $(uname) = dsdss ]] && echo 'y'will not echo anything. – terdon Apr 12 '14 at 20:01