[zsh] Move init_rc_configure_ls to init_configure_ls
This commit is contained in:
		
							parent
							
								
									8eebcd73de
								
							
						
					
					
						commit
						ed13222d7f
					
				
					 3 changed files with 43 additions and 48 deletions
				
			
		
							
								
								
									
										33
									
								
								zsh/func/init_configure_ls
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								zsh/func/init_configure_ls
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,33 @@
 | 
				
			||||||
 | 
					#!/usr/bin/env zsh
 | 
				
			||||||
 | 
					# Eryn Wells <eryn@erynwells.me>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local has_gnu_ls
 | 
				
			||||||
 | 
					local ls_options
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [[ ! -e "$1" ]]; then
 | 
				
			||||||
 | 
					    return
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if $1 --version 2>&1 | grep GNU 1>/dev/null; then
 | 
				
			||||||
 | 
					    has_gnu_ls=1
 | 
				
			||||||
 | 
					    ls_options='--color=auto'
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					    has_gnu_ls=0
 | 
				
			||||||
 | 
					    ls_options='-G'
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					alias ls="$1 $ls_options"
 | 
				
			||||||
 | 
					alias la="$1 -A $ls_options"
 | 
				
			||||||
 | 
					alias ll="$1 -l $ls_options"
 | 
				
			||||||
 | 
					alias l.="$1 -d $ls_options .*"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local dircolors_bin=`whence -p dircolors || whence -p gdircolors`
 | 
				
			||||||
 | 
					if [[ $has_gnu_ls -eq 1 && -n "$dircolors_bin" ]]; then
 | 
				
			||||||
 | 
					    if [[ -e "$HOME/.dircolors/$SYS.cfg" ]]; then
 | 
				
			||||||
 | 
					        dircolors="$HOME/.dircolors/$SYS.cfg"
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					        dircolors="$HOME/.dircolors/default.cfg"
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    eval `$dircolors_bin $dircolors`
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
| 
						 | 
					@ -1,38 +0,0 @@
 | 
				
			||||||
#!/usr/bin/env zsh
 | 
					 | 
				
			||||||
# Eryn Wells <eryn@erynwells.me>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function init_configure_ls
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    local has_gnu_ls
 | 
					 | 
				
			||||||
    local ls_options
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if [[ ! -e "$1" ]]; then
 | 
					 | 
				
			||||||
        return
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if $1 --version 2>&1 | grep GNU 1>/dev/null; then
 | 
					 | 
				
			||||||
        has_gnu_ls=1
 | 
					 | 
				
			||||||
        ls_options='--color=auto'
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
        has_gnu_ls=0
 | 
					 | 
				
			||||||
        ls_options='-G'
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    alias ls="$1 $ls_options"
 | 
					 | 
				
			||||||
    alias la="$1 -A $ls_options"
 | 
					 | 
				
			||||||
    alias ll="$1 -l $ls_options"
 | 
					 | 
				
			||||||
    alias l.="$1 -d $ls_options .*"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    local dircolors_bin=`whence -p dircolors || whence -p gdircolors`
 | 
					 | 
				
			||||||
    if [[ $has_gnu_ls -eq 1 && -n "$dircolors_bin" ]]; then
 | 
					 | 
				
			||||||
        if [[ -e "$HOME/.dircolors/$SYS.cfg" ]]; then
 | 
					 | 
				
			||||||
            dircolors="$HOME/.dircolors/$SYS.cfg"
 | 
					 | 
				
			||||||
        else
 | 
					 | 
				
			||||||
            dircolors="$HOME/.dircolors/default.cfg"
 | 
					 | 
				
			||||||
        fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        eval `$dircolors_bin $dircolors`
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
init_configure_ls "$@"
 | 
					 | 
				
			||||||
							
								
								
									
										20
									
								
								zshrc
									
										
									
									
									
								
							
							
						
						
									
										20
									
								
								zshrc
									
										
									
									
									
								
							| 
						 | 
					@ -1,15 +1,15 @@
 | 
				
			||||||
#!/usr/bin/env zsh
 | 
					#!/usr/bin/env zsh
 | 
				
			||||||
# Eryn Wells <eryn@erynwells.me>
 | 
					# Eryn Wells <eryn@erynwells.me>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
autoload +X init_app_environments
 | 
					autoload -Uz init_app_environments
 | 
				
			||||||
autoload +X init_rc_aliases
 | 
					autoload -Uz init_configure_ls
 | 
				
			||||||
autoload +X init_rc_configure_completion
 | 
					autoload -Uz init_rc_aliases
 | 
				
			||||||
autoload +X init_rc_configure_ls
 | 
					autoload -Uz init_rc_configure_completion
 | 
				
			||||||
autoload +X init_rc_configure_prompt
 | 
					autoload -Uz init_rc_configure_prompt
 | 
				
			||||||
autoload +X init_rc_configure_zle
 | 
					autoload -Uz init_rc_configure_zle
 | 
				
			||||||
autoload +X init_zsh_options
 | 
					autoload -Uz init_zsh_options
 | 
				
			||||||
autoload +X init_zsh_history
 | 
					autoload -Uz init_zsh_history
 | 
				
			||||||
autoload +X init_zsh_functions
 | 
					autoload -Uz init_zsh_functions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
init_rc_aliases
 | 
					init_rc_aliases
 | 
				
			||||||
init_rc_configure_prompt loquacious
 | 
					init_rc_configure_prompt loquacious
 | 
				
			||||||
| 
						 | 
					@ -25,7 +25,7 @@ init_rc_$SYS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Configure ls with the system ls if it hasn't been done already.
 | 
					# Configure ls with the system ls if it hasn't been done already.
 | 
				
			||||||
if ! alias ls 2>&1 1>/dev/null; then
 | 
					if ! alias ls 2>&1 1>/dev/null; then
 | 
				
			||||||
    init_rc_configure_ls `which ls`
 | 
					    init_configure_ls `which ls`
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
autoload g
 | 
					autoload g
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue