mirror of
				https://github.com/dcarrillo/prezto.git
				synced 2025-11-04 01:39:09 +00:00 
			
		
		
		
	Compare commits
	
		
			4 Commits
		
	
	
		
			865cc2ef02
			...
			pull/628-e
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					9ab6ab0d66 | ||
| 
						 | 
					0a3d29ce5e | ||
| 
						 | 
					366cadecf0 | ||
| 
						 | 
					3debe8bdf6 | 
							
								
								
									
										11
									
								
								modules/explainshell/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								modules/explainshell/README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
#Explainshell
 | 
			
		||||
 | 
			
		||||
Adds a keybinding and a function to open 
 | 
			
		||||
[explainshell.com](http://www.explainshell.com) with the content of the command
 | 
			
		||||
line.
 | 
			
		||||
 | 
			
		||||
##Settings
 | 
			
		||||
###Key-Binding
 | 
			
		||||
The keybinding to open [explainshell.com](http://www.explainshell.com)
 | 
			
		||||
 | 
			
		||||
`zstyle ':prezto:module:explainshell' key-binding '^K'`
 | 
			
		||||
							
								
								
									
										63
									
								
								modules/explainshell/init.zsh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								modules/explainshell/init.zsh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,63 @@
 | 
			
		||||
#
 | 
			
		||||
# Adds a explain function and explainshell widget
 | 
			
		||||
# 
 | 
			
		||||
# Authors
 | 
			
		||||
#   C Lentfort
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
function _expand_alias_recursive {
 | 
			
		||||
  local _alias
 | 
			
		||||
  for word in "$@"; do
 | 
			
		||||
    # Check if word is aliased
 | 
			
		||||
    _alias=$aliases[$word]
 | 
			
		||||
    if [ -n "$_alias" ]; then
 | 
			
		||||
      # Check if found alias and given command are identical
 | 
			
		||||
      if [[ "$_alias" != "${(j: :)@}" ]]; then
 | 
			
		||||
        _expand_alias_recursive "${(z)_alias}"
 | 
			
		||||
      else
 | 
			
		||||
        _explainshell_expanded_buffer+=$1
 | 
			
		||||
      fi
 | 
			
		||||
    else
 | 
			
		||||
      _explainshell_expanded_buffer+=$word
 | 
			
		||||
    fi
 | 
			
		||||
  done
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function explain {
 | 
			
		||||
  local url
 | 
			
		||||
  # We don't explain empty buffers
 | 
			
		||||
  if (( $# == 0 )); then
 | 
			
		||||
    return 1;
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  # Replace aliases with their actual expansions
 | 
			
		||||
  _explainshell_expanded_buffer=()
 | 
			
		||||
  _expand_alias_recursive $@
 | 
			
		||||
  _explainshell_expanded_buffer=(${(u)_explainshell_expanded_buffer})
 | 
			
		||||
  # base url with first command already injected
 | 
			
		||||
  # $ explain tar
 | 
			
		||||
  #   => http://explainshel.com/explain/tar?args=
 | 
			
		||||
  url="http://explainshell.com/explain?cmd="
 | 
			
		||||
 | 
			
		||||
  # iterates over remaining args and adds builds the rest of the url
 | 
			
		||||
  for i in "$_explainshell_expanded_buffer"; do
 | 
			
		||||
    url=$url"$i""+"
 | 
			
		||||
  done
 | 
			
		||||
 | 
			
		||||
  unset _explainshell_expanded_buffer
 | 
			
		||||
  # opens url in browser
 | 
			
		||||
  $BROWSER -t $url &> /dev/null
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function explainshell {
 | 
			
		||||
  explain ${(z)BUFFER}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
zle -N explainshell
 | 
			
		||||
 | 
			
		||||
zstyle -s ':prezto:module:explainshell' key-binding 'key_binding'
 | 
			
		||||
if [[ -n "$key_binding" ]]; then
 | 
			
		||||
  bindkey "$key_binding" explainshell
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
unset key_binding
 | 
			
		||||
@@ -28,6 +28,9 @@ elif (( $+commands[chruby-exec] )); then
 | 
			
		||||
  source "${commands[chruby-exec]:h:h}/share/chruby/chruby.sh"
 | 
			
		||||
  if zstyle -t ':prezto:module:ruby:chruby' auto-switch; then
 | 
			
		||||
    source "${commands[chruby-exec]:h:h}/share/chruby/auto.sh"
 | 
			
		||||
 | 
			
		||||
    # If a default Ruby is set, switch to it.
 | 
			
		||||
    chruby_auto
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
# Prepend local gems bin directories to PATH.
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,8 @@ SSH
 | 
			
		||||
Provides for an easier use of [SSH][1] by setting up [ssh-agent][2].
 | 
			
		||||
 | 
			
		||||
This module is disabled on Mac OS X due to custom Apple SSH support rendering it
 | 
			
		||||
unnecessary.
 | 
			
		||||
unnecessary. Use `ssh-add -K` to store identities in Keychain; they will be
 | 
			
		||||
added to `ssh-agent` automatically and persist between reboots.
 | 
			
		||||
 | 
			
		||||
Settings
 | 
			
		||||
--------
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user