mirror of
				https://github.com/zsh-users/zsh-autosuggestions.git
				synced 2025-10-30 15:26:29 +08:00 
			
		
		
		
	 767d55eba0
			
		
	
	
		767d55eba0
		
	
	
	
	
		
			
			If zle is already active (plugin has been loaded in the background), just start the widgets and set up the automatic re-binding (if manual rebind has not been specified). See GitHub issue #481
		
			
				
	
	
		
			32 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
| 
 | |
| #--------------------------------------------------------------------#
 | |
| # Start                                                              #
 | |
| #--------------------------------------------------------------------#
 | |
| 
 | |
| # Start the autosuggestion widgets
 | |
| _zsh_autosuggest_start() {
 | |
| 	# By default we re-bind widgets on every precmd to ensure we wrap other
 | |
| 	# wrappers. Specifically, highlighting breaks if our widgets are wrapped by
 | |
| 	# zsh-syntax-highlighting widgets. This also allows modifications to the
 | |
| 	# widget list variables to take effect on the next precmd. However this has
 | |
| 	# a decent performance hit, so users can set ZSH_AUTOSUGGEST_MANUAL_REBIND
 | |
| 	# to disable the automatic re-binding.
 | |
| 	if (( ${+ZSH_AUTOSUGGEST_MANUAL_REBIND} )); then
 | |
| 		add-zsh-hook -d precmd _zsh_autosuggest_start
 | |
| 	fi
 | |
| 
 | |
| 	_zsh_autosuggest_bind_widgets
 | |
| }
 | |
| 
 | |
| # Mark for auto-loading the functions that we use
 | |
| autoload -Uz add-zsh-hook is-at-least
 | |
| 
 | |
| # If zle is already running, go ahead and start the autosuggestion widgets.
 | |
| # Otherwise, wait until the next precmd.
 | |
| if zle; then
 | |
| 	_zsh_autosuggest_start
 | |
| 	(( ! ${+ZSH_AUTOSUGGEST_MANUAL_REBIND} )) && add-zsh-hook precmd _zsh_autosuggest_start
 | |
| else
 | |
| 	add-zsh-hook precmd _zsh_autosuggest_start
 | |
| fi
 |