mirror of
				https://github.com/ohmyzsh/ohmyzsh.git
				synced 2025-11-04 13:21:19 +08:00 
			
		
		
		
	feat(cli): add --enabled flag to omz plugin list (#13128)
				
					
				
			This commit is contained in:
		
							parent
							
								
									ecdc1e722a
								
							
						
					
					
						commit
						095ac3ca8f
					
				
							
								
								
									
										23
									
								
								lib/cli.zsh
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								lib/cli.zsh
									
									
									
									
									
								
							@ -72,6 +72,10 @@ function _omz {
 | 
			
		||||
        local -aU plugins
 | 
			
		||||
        plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
 | 
			
		||||
        _describe 'plugin' plugins ;;
 | 
			
		||||
      plugin::list)
 | 
			
		||||
        local -a opts
 | 
			
		||||
        opts=('--enabled:List enabled plugins only')
 | 
			
		||||
        _describe -o 'options' opts ;;
 | 
			
		||||
      theme::(set|use))
 | 
			
		||||
        local -aU themes
 | 
			
		||||
        themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
 | 
			
		||||
@ -206,7 +210,7 @@ Available commands:
 | 
			
		||||
  disable <plugin> Disable plugin(s)
 | 
			
		||||
  enable <plugin>  Enable plugin(s)
 | 
			
		||||
  info <plugin>    Get information of a plugin
 | 
			
		||||
  list             List all available Oh My Zsh plugins
 | 
			
		||||
  list [--enabled] List Oh My Zsh plugins
 | 
			
		||||
  load <plugin>    Load plugin(s)
 | 
			
		||||
 | 
			
		||||
EOF
 | 
			
		||||
@ -449,8 +453,21 @@ function _omz::plugin::info {
 | 
			
		||||
 | 
			
		||||
function _omz::plugin::list {
 | 
			
		||||
  local -a custom_plugins builtin_plugins
 | 
			
		||||
  custom_plugins=("$ZSH_CUSTOM"/plugins/*(-/N:t))
 | 
			
		||||
  builtin_plugins=("$ZSH"/plugins/*(-/N:t))
 | 
			
		||||
 | 
			
		||||
  # If --enabled is provided, only list what's enabled
 | 
			
		||||
  if [[ "$1" == "--enabled" ]]; then
 | 
			
		||||
    local plugin
 | 
			
		||||
    for plugin in "${plugins[@]}"; do
 | 
			
		||||
      if [[ -d "${ZSH_CUSTOM}/plugins/${plugin}" ]]; then
 | 
			
		||||
        custom_plugins+=("${plugin}")
 | 
			
		||||
      elif [[ -d "${ZSH}/plugins/${plugin}" ]]; then
 | 
			
		||||
        builtin_plugins+=("${plugin}")
 | 
			
		||||
      fi
 | 
			
		||||
    done
 | 
			
		||||
  else
 | 
			
		||||
    custom_plugins=("$ZSH_CUSTOM"/plugins/*(-/N:t))
 | 
			
		||||
    builtin_plugins=("$ZSH"/plugins/*(-/N:t))
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  # If the command is being piped, print all found line by line
 | 
			
		||||
  if [[ ! -t 1 ]]; then
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user