FZF: Add default options and prompt
This commit is contained in:
		
							parent
							
								
									87ce125e42
								
							
						
					
					
						commit
						5c6b4d46a9
					
				
							
								
								
									
										59
									
								
								zshrc
								
								
								
								
							
							
						
						
									
										59
									
								
								zshrc
								
								
								
								
							|  | @ -1806,6 +1806,8 @@ if [ -f ~/bin/fd ]; then | |||
| 	export FZF_DEFAULT_COMMAND='fd --type f' | ||||
| fi | ||||
| 
 | ||||
| export FZF_DEFAULT_OPTS="--cycle --multi --select-1 --bind change:first" | ||||
| 
 | ||||
| # Auto-completion | ||||
| # --------------- | ||||
| [[ $- == *i* ]] && source "${HOME}/.fzf/shell/completion.zsh" 2> /dev/null | ||||
|  | @ -1826,10 +1828,10 @@ ff() { | |||
| 	## Manage argument {{{ | ||||
| 	if [ "${#}" -eq "0" ]; then | ||||
| 		## Default command without args | ||||
| 		dir=$(find . -xtype d -not -path "*/.*" | fzf --height=50% --preview 'exa --tree --level 2 {} | head --lines=20' --no-multi) && | ||||
| 		dir=$(find . -xtype d -not -path "*/.*" | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 2 {} | head --lines=20' --no-multi) && | ||||
| 	else | ||||
| 		## If at least one argument was given, add it to fzf query | ||||
| 		dir=$(find . -xtype d -not -path "*/.*" | fzf --height=50% --preview 'exa --tree --level 2 {} | head --lines=20' --no-multi --query "${*} ") && | ||||
| 		dir=$(find . -xtype d -not -path "*/.*" | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 2 {} | head --lines=20' --no-multi --query "${*} ") && | ||||
| 	fi | ||||
| 	## }}} | ||||
| 
 | ||||
|  | @ -1848,10 +1850,10 @@ ffh() { | |||
| 	## Manage argument {{{ | ||||
| 	if [ "${#}" -eq "0" ]; then | ||||
| 		## Default command without args | ||||
| 		dir=$(find . -xtype d -path "*/.*" | fzf --height=50% --preview 'exa --tree --level 2 {} | head --lines=20' --no-multi) && | ||||
| 		dir=$(find . -xtype d -path "*/.*" | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 2 {} | head --lines=20' --no-multi) && | ||||
| 	else | ||||
| 		## If at least one argument was given, add it to fzf query | ||||
| 		dir=$(find . -xtype d -path "*/.*" | fzf --height=50% --preview 'exa --tree --level 2 {} | head --lines=20' --no-multi --query "${*} ") && | ||||
| 		dir=$(find . -xtype d -path "*/.*" | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 2 {} | head --lines=20' --no-multi --query "${*} ") && | ||||
| 	fi | ||||
| 	## }}} | ||||
| 
 | ||||
|  | @ -1870,10 +1872,10 @@ ffa() { | |||
| 	## Manage argument {{{ | ||||
| 	if [ "${#}" -eq "0" ]; then | ||||
| 		## Default command without args | ||||
| 		dir=$(fd -uu --search-path / --type d --type symlink | fzf --height=50% --preview 'exa --tree --level 1 {} | head --lines=20' --no-multi) && | ||||
| 		dir=$(fd -uu --search-path / --type d --type symlink | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 1 {} | head --lines=20' --no-multi) && | ||||
| 	else | ||||
| 		## If at least one argument was given, add it to fzf query | ||||
| 		dir=$(fd -uu --search-path / --type d --type symlink | fzf --height=50% --preview 'exa --tree --level 1 {} | head --lines=20' --no-multi --query "${*} ") && | ||||
| 		dir=$(fd -uu --search-path / --type d --type symlink | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 1 {} | head --lines=20' --no-multi --query "${*} ") && | ||||
| 	fi | ||||
| 	## }}} | ||||
| 
 | ||||
|  | @ -1898,10 +1900,10 @@ ffu() { | |||
| 	## Manage argument {{{ | ||||
| 	if [ "${#}" -eq "0" ]; then | ||||
| 		## Default command without args | ||||
| 		dir=$(get_parent_dirs $(realpath "${PWD}") | fzf --tac --height=50% --no-multi) && | ||||
| 		dir=$(get_parent_dirs $(realpath "${PWD}") | fzf --prompt='cd> ' --tac --height=50% --no-multi) && | ||||
| 	else | ||||
| 		## If at least one argument was given, add it to fzf query | ||||
| 		dir=$(get_parent_dirs $(realpath "${PWD}") | fzf --tac --height=50% --no-multi --query "${*} ") && | ||||
| 		dir=$(get_parent_dirs $(realpath "${PWD}") | fzf --prompt='cd> ' --tac --height=50% --no-multi --query "${*} ") && | ||||
| 	fi | ||||
| 	## }}} | ||||
| 
 | ||||
|  | @ -1921,10 +1923,10 @@ fff() { | |||
| 	## Manage argument {{{ | ||||
| 	if [ "${#}" -eq "0" ]; then | ||||
| 		## Default command without args | ||||
| 		file=$(find . -xtype f | fzf --height=50% --preview 'exa --tree --level 2 $(dirname {}) | head --lines=20' --no-multi) && | ||||
| 		file=$(find . -xtype f | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 2 $(dirname {}) | head --lines=20' --no-multi) && | ||||
| 	else | ||||
| 		## If at least one argument was given, add it to fzf query | ||||
| 		file=$(find . -xtype f | fzf --height=50% --preview 'exa --tree --level 2 $(dirname {}) | head --lines=20' --no-multi --query "${*} ") && | ||||
| 		file=$(find . -xtype f | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 2 $(dirname {}) | head --lines=20' --no-multi --query "${*} ") && | ||||
| 	fi | ||||
| 	## }}} | ||||
| 
 | ||||
|  | @ -1943,11 +1945,10 @@ cf() { | |||
| 	## Manage argument {{{ | ||||
| 	if [ "${#}" -eq "0" ]; then | ||||
| 		## Default command without args | ||||
| 		#file="$(locate -Ai -0 $@ | grep -z -vE '~$' | fzf --read0 -0 -1)" | ||||
| 		file=$(fd -uu --search-path / | fzf --height=50% --preview 'exa --tree --level 1 $(dirname {}) | head --lines=20' --no-multi) && | ||||
| 		file=$(fd -uu --search-path / | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 1 $(dirname {}) | head --lines=20' --no-multi) && | ||||
| 	else | ||||
| 		## If at least one argument was given, add it to fzf query | ||||
| 		file=$(fd -uu --search-path / | fzf --height=50% --preview 'exa --tree --level 1 $(dirname {}) | head --lines=20' --no-multi --query "${*} ") && | ||||
| 		file=$(fd -uu --search-path / | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 1 $(dirname {}) | head --lines=20' --no-multi --query "${*} ") && | ||||
| 	fi | ||||
| 	## }}} | ||||
| 
 | ||||
|  | @ -1980,10 +1981,10 @@ v() { | |||
| 	## Manage argument {{{ | ||||
| 	if [ "${#}" -eq "0" ]; then | ||||
| 		## Default command without args | ||||
| 		files=$(fd -uu --type file --type symlink | fzf --preview 'bat --color=always --line-range 0:50 {}' --no-multi) && | ||||
| 		files=$(fd -uu --type file --type symlink | fzf --prompt='vi> ' --preview 'bat --color=always --line-range 0:50 {}' --no-multi) && | ||||
| 	else | ||||
| 		## If at least one argument was given, add it to fzf query | ||||
| 		files=$(fd -uu --type file --type symlink | fzf --preview 'bat --color=always --line-range 0:50 {}' --no-multi --query "${*} ") && | ||||
| 		files=$(fd -uu --type file --type symlink | fzf --prompt='vi> ' --preview 'bat --color=always --line-range 0:50 {}' --no-multi --query "${*} ") && | ||||
| 	fi | ||||
| 	## }}} | ||||
| 
 | ||||
|  | @ -2015,10 +2016,10 @@ pdf() { | |||
| 	## Manage argument {{{ | ||||
| 	if [ "${#}" -eq "0" ]; then | ||||
| 		## Default command without args | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --preview 'lesspipe {} | less' --no-multi) && | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi) && | ||||
| 	else | ||||
| 		## If at least one argument was given, add it to fzf query | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --preview 'lesspipe {} | less' --no-multi --query "${*} ") && | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi --query "${*} ") && | ||||
| 	fi | ||||
| 	## }}} | ||||
| 
 | ||||
|  | @ -2055,10 +2056,10 @@ pdfe() { | |||
| 	## Manage argument {{{ | ||||
| 	if [ "${#}" -eq "0" ]; then | ||||
| 		## Default command without args | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --preview 'lesspipe {} | less' --no-multi) && | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi) && | ||||
| 	else | ||||
| 		## If at least one argument was given, add it to fzf query | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --preview 'lesspipe {} | less' --no-multi --query "${*} ") && | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi --query "${*} ") && | ||||
| 	fi | ||||
| 	## }}} | ||||
| 
 | ||||
|  | @ -2095,10 +2096,10 @@ pdfz() { | |||
| 	## Manage argument {{{ | ||||
| 	if [ "${#}" -eq "0" ]; then | ||||
| 		## Default command without args | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --preview 'lesspipe {} | less' --no-multi) && | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi) && | ||||
| 	else | ||||
| 		## If at least one argument was given, add it to fzf query | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --preview 'lesspipe {} | less' --no-multi --query "${*} ") && | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi --query "${*} ") && | ||||
| 	fi | ||||
| 	## }}} | ||||
| 
 | ||||
|  | @ -2126,10 +2127,10 @@ odt() { | |||
| 	## Manage argument {{{ | ||||
| 	if [ "${#}" -eq "0" ]; then | ||||
| 		## Default command without args | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.(odt|rtf|doc|docx)" | fzf --no-multi) && | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.(odt|rtf|doc|docx)" | fzf --prompt='odt> ' --no-multi) && | ||||
| 	else | ||||
| 		## If at least one argument was given, add it to fzf query | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.(odt|rtf|doc|docx)" | fzf --no-multi --query "${*} ") && | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.(odt|rtf|doc|docx)" | fzf --prompt='odt> ' --no-multi --query "${*} ") && | ||||
| 	fi | ||||
| 	## }}} | ||||
| 
 | ||||
|  | @ -2156,10 +2157,10 @@ ods() { | |||
| 	## Manage argument {{{ | ||||
| 	if [ "${#}" -eq "0" ]; then | ||||
| 		## Default command without args | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.(ods|xls|xlsx)" | fzf --no-multi) && | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.(ods|xls|xlsx)" | fzf --prompt='ods> ' --no-multi) && | ||||
| 	else | ||||
| 		## If at least one argument was given, add it to fzf query | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.(ods|xls|xlsx)" | fzf --no-multi --query "${*} ") && | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.(ods|xls|xlsx)" | fzf --prompt='ods> ' --no-multi --query "${*} ") && | ||||
| 	fi | ||||
| 	## }}} | ||||
| 
 | ||||
|  | @ -2186,10 +2187,10 @@ odp() { | |||
| 	## Manage argument {{{ | ||||
| 	if [ "${#}" -eq "0" ]; then | ||||
| 		## Default command without args | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.(odp|ppt|pptx)" | fzf --no-multi) && | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.(odp|ppt|pptx)" | fzf --prompt='odp> ' --no-multi) && | ||||
| 	else | ||||
| 		## If at least one argument was given, add it to fzf query | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.(odp|ppt|pptx)" | fzf --no-multi "${*} ") && | ||||
| 		files=$(fd --unrestricted --type file --type symlink "\.(odp|ppt|pptx)" | fzf --prompt='odp> ' --no-multi "${*} ") && | ||||
| 	fi | ||||
| 	## }}} | ||||
| 
 | ||||
|  | @ -2217,10 +2218,10 @@ fopen() { | |||
| 	## Manage argument {{{ | ||||
| 	if [ "${#}" -le "1" ]; then | ||||
| 		## Default command with one argument or default value | ||||
| 		files=$(fd --unrestricted --type file --type symlink "${1:-.}" | fzf --no-multi) && | ||||
| 		files=$(fd --unrestricted --type file --type symlink "${1:-.}" | fzf --prompt='open> ' --no-multi) && | ||||
| 	else | ||||
| 		## If at least one argument was given, add it to fzf query | ||||
| 		files=$(fd --unrestricted --type file --type symlink "${1:-.}" | fzf --no-multi --query "${*} ") && | ||||
| 		files=$(fd --unrestricted --type file --type symlink "${1:-.}" | fzf --prompt='open> ' --no-multi --query "${*} ") && | ||||
| 	fi | ||||
| 	## }}} | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue