From 4315126ae683a32d3310f565629309c98cd11f97 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sun, 15 Sep 2013 18:04:02 +0100 Subject: zsh: Refactor and improve cross-platform handling of ls options --- zsh/zshrc | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'zsh/zshrc') diff --git a/zsh/zshrc b/zsh/zshrc index d6ae52ea..bbfa9301 100755 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -83,13 +83,9 @@ fi case $OSTYPE in *gnu*) os=gnu - ls_options="-v --group-directories-first --color=auto" - ls_isodate="--time-style=long-iso" ;; freebsd*) os=freebsd - ls_options="-p" - ls_isodate="-D '%F %k:%M'" ;; darwin*) os=osx @@ -264,12 +260,33 @@ alias md='mkdir -p' alias rd='rmdir' alias .='source' -if [[ $os == osx ]] -then - ls='\gls' -else - ls='\ls' -fi +ls='\ls' +gnu_ls_options="-v --group-directories-first --color=auto" +gnu_ls_isodate="--time-style=long-iso" +bsd_ls_options="-p" +bsd_ls_isodate="-D '%F %k:%M'" + +case $os in + osx) + if [[ -n $commands[gls] ]] + then + ls='\gls' + ls_options=$gnu_ls_options + ls_isodate=$gnu_ls_isodate + else + ls_options=$bsd_ls_options + ls_isodate=$bsd_ls_isodate + fi + ;; + freebsd) + ls_options=$bsd_ls_options + ls_isodate=$bsd_ls_isodate + ;; + gnu) + ls_options=$gnu_ls_options + ls_isodate=$gnu_ls_isodate + ;; +esac alias l="${ls} ${ls_options} -Bp" alias l1="${ls} ${ls_options} -1" alias ls="${ls} ${ls_options} -hF" -- cgit 1.4.1