plugin/fzf: `shellcheck`
parent
0d813d2376
commit
37c79b86b6
|
|
@ -1,42 +1,43 @@
|
||||||
# Load after the system completion to make sure that the fzf completions are working
|
# shellcheck shell=bash
|
||||||
# BASH_IT_LOAD_PRIORITY: 375
|
|
||||||
|
|
||||||
cite about-plugin
|
|
||||||
about-plugin 'load fzf, if you are using it'
|
about-plugin 'load fzf, if you are using it'
|
||||||
|
|
||||||
if [ -r ~/.fzf.bash ] ; then
|
# shellcheck source-path=$HOME source-path=$HOME/.config/fzf disable=SC1090 disable=SC1091
|
||||||
source ~/.fzf.bash
|
if [[ -r ~/.fzf.bash ]]; then
|
||||||
elif [ -r "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash ] ; then
|
source ~/.fzf.bash
|
||||||
source "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash
|
elif [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/fzf/fzf.bash" ]]; then
|
||||||
|
source "${XDG_CONFIG_HOME:-$HOME/.config}/fzf/fzf.bash"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# No need to continue if the command is not present
|
# No need to continue if the command is not present
|
||||||
_command_exists fzf || return
|
if ! _binary_exists fzf; then
|
||||||
|
_log_warning "unable to initialize without '$_' installed."
|
||||||
if [ -z ${FZF_DEFAULT_COMMAND+x} ] && _command_exists fd ; then
|
return 1
|
||||||
export FZF_DEFAULT_COMMAND='fd --type f'
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fe() {
|
if [[ -z ${FZF_DEFAULT_COMMAND+x} ]] && _command_exists fd; then
|
||||||
about "Open the selected file in the default editor"
|
export FZF_DEFAULT_COMMAND='fd --type f'
|
||||||
group "fzf"
|
fi
|
||||||
param "1: Search term"
|
|
||||||
example "fe foo"
|
|
||||||
|
|
||||||
local IFS=$'\n'
|
function fe() {
|
||||||
local files
|
about "Open the selected file in the default editor"
|
||||||
files=($(fzf-tmux --query="$1" --multi --select-1 --exit-0))
|
group "fzf"
|
||||||
[[ -n "$files" ]] && ${EDITOR:-vim} "${files[@]}"
|
param "1: Search term"
|
||||||
|
example "fe foo"
|
||||||
|
|
||||||
|
local IFS=$'\n'
|
||||||
|
local files
|
||||||
|
read -ra files < <(fzf-tmux --query="$1" --multi --select-1 --exit-0)
|
||||||
|
[[ -n "${files[*]}" ]] && "${EDITOR:-${ALTERNATE_EDITOR:-nano}}" "${files[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
fcd() {
|
function fcd() {
|
||||||
about "cd to the selected directory"
|
about "cd to the selected directory"
|
||||||
group "fzf"
|
group "fzf"
|
||||||
param "1: Directory to browse, or . if omitted"
|
param "1: Directory to browse, or . if omitted"
|
||||||
example "fcd aliases"
|
example "fcd aliases"
|
||||||
|
|
||||||
local dir
|
local dir
|
||||||
dir=$(find ${1:-.} -path '*/\.*' -prune \
|
dir=$(find "${1:-.}" -path '*/\.*' -prune \
|
||||||
-o -type d -print 2> /dev/null | fzf +m) &&
|
-o -type d -print 2> /dev/null | fzf +m) \
|
||||||
cd "$dir"
|
&& cd "$dir" || return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue