Bash LS Options ~ Group Directories First

3

Locally I'm running Debian stable ~ bash -version 4.1.5 ...
Remotely my server is running Centos 5-8.el5 bash -version 3.2.25 ...

I have a .bash_alias file on both distros containing an alias 'll' for ls option --group-directories-first ... However, this option fails remotely ...

##############################################################                                                    
#                       BASH_ALIASES                                                                              
##############################################################                                                    
#-------------------------------------------------------------                                                    
# The 'ls' family                                                                                                 
#-------------------------------------------------------------                                                    
alias ll="ls -l --group-directories-first"                                                                        
alias ls='ls -hF --color'  # add colors for filetype recognition                                                  
alias la='ls -Al'          # show hidden files                                                                    
alias lx='ls -lXB'         # sort by extension                                                                    
alias lk='ls -lSr'         # sort by size, biggest last                                                           
alias lc='ls -ltcr'        # sort by and show change time, most recent last                                       
alias lu='ls -ltur'        # sort by and show access time, most recent last                                       
alias lt='ls -ltr'         # sort by date, most recent last                                                       
alias lm='ls -al |more'    # pipe through 'more'                                                                  
alias lr='ls -lR'          # recursive ls                                                                         
alias tree='tree -Csu'     # nice alternative to 'recursive ls'                                                   

# ------------------------------------------------------------                                                    
# Play nicely ...                                                                                                 
# ------------------------------------------------------------                                                    
alias rm='rm -i'                                                                                                  
alias rmdir='rmdir -p'                                                                                            
alias cp='cp -i'                                                                                                  
alias mv='mv -i'                                                                                                  
alias mkdir='mkdir -p'

Is this simply a difference in bash versions?

Eddie B

Posted 2012-05-08T19:46:52.693

Reputation: 909

Answers

3

The .bash_alias file is non-standard and must be explicitly loaded in one of the automatically loaded files, e.g. .bashrc or .bash_profile. Use the following script snippet:

[[ -f ~/.bash_alias ]] && . .bash_alias

Make sure you are including .bash_alias in the correct one; local Linux terminals usually don't start login shells, so you'd use .bashrc, but via SSH on the remote system, bash will only load .bash_profile automatically. See the section INVOCATION in man bash.

Daniel Beck

Posted 2012-05-08T19:46:52.693

Reputation: 98 421

Thanks for the reply ... I should have been more specific in stating that I have ~/.bashrc with the same on both boxes ...

Here's .bashrc's contents both locally and remote ... – Eddie B – 2012-05-08T21:14:59.610

if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi – Eddie B – 2012-05-08T21:24:54.117

Please read my entire answer. What use is a bashrc file when it won't get loaded in login shells? – Daniel Beck – 2012-05-08T21:28:10.427

Ahh ... I'll check out Invocation ... appreciate the help ... – Eddie B – 2012-05-08T21:31:14.590