-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plugins: clear and consistent log messages
- Loading branch information
1 parent
b2ea85a
commit b9e1535
Showing
22 changed files
with
203 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
cite about-plugin | ||
# shellcheck shell=bash | ||
about-plugin 'Simplify `curl cht.sh/<query>` to `cht.sh <query>`' | ||
|
||
# Play nicely if user already installed cht.sh cli tool | ||
if ! _command_exists cht.sh ; then | ||
function cht.sh () { | ||
about 'Executes a cht.sh curl query using the provided arguments' | ||
param ' [ ( topic [sub-topic] ) | ~keyword ] [ :list | :help | :learn ]' | ||
example '$ cht.sh :help' | ||
example '$ cht.sh :list' | ||
example '$ cht.sh tar' | ||
example '$ cht.sh js "parse json"' | ||
example '$ cht.sh python :learn' | ||
example '$ cht.sh rust :list' | ||
group 'cht-sh' | ||
|
||
# Separate arguments with '/', preserving spaces within them | ||
local query=$(IFS=/ ; echo "$*") | ||
curl "cht.sh/${query}" | ||
} | ||
if _binary_exists cht.sh ; then | ||
_log_warning "You have already installed `cht.sh`, so it's safe to disable this plugin." | ||
return 1 | ||
fi | ||
|
||
function cht.sh () { | ||
about 'Executes a cht.sh curl query using the provided arguments' | ||
param ' [ ( topic [sub-topic] ) | ~keyword ] [ :list | :help | :learn ]' | ||
example '$ cht.sh :help' | ||
example '$ cht.sh :list' | ||
example '$ cht.sh tar' | ||
example '$ cht.sh js "parse json"' | ||
example '$ cht.sh python :learn' | ||
example '$ cht.sh rust :list' | ||
group 'cht-sh' | ||
|
||
# Separate arguments with '/', preserving spaces within them | ||
local query | ||
query=$(IFS=/ ; echo "$*") | ||
curl "cht.sh/${query}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
# shellcheck shell=bash | ||
cite about-plugin | ||
about-plugin 'load direnv, if you are using it: https://direnv.net/' | ||
|
||
if _command_exists direnv; then | ||
eval "$(direnv hook bash)" | ||
if ! _binary_exists direnv; then | ||
_log_warning "Could not find 'direnv'." | ||
return 1 | ||
fi | ||
|
||
# shellcheck disable=SC1090 | ||
source < <(direnv hook bash) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
cite about-plugin | ||
# shellcheck shell=bash | ||
about-plugin 'load fasd, if you are using it' | ||
|
||
_command_exists fasd || return | ||
if ! _binary_exists fasd; then | ||
_log_warning "Unable to locage 'fasd'." | ||
fi | ||
|
||
eval "$(fasd --init auto)" | ||
# shellcheck disable=SC1090 | ||
source < <(fasd --init auto) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,43 @@ | ||
# Load after the system completion to make sure that the fzf completions are working | ||
# BASH_IT_LOAD_PRIORITY: 375 | ||
|
||
cite about-plugin | ||
# shellcheck shell=bash | ||
about-plugin 'load fzf, if you are using it' | ||
|
||
if [ -r ~/.fzf.bash ] ; then | ||
source ~/.fzf.bash | ||
elif [ -r "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash ] ; then | ||
source "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash | ||
# shellcheck source-path=$HOME source-path=$HOME/.config/fzf disable=SC1090 disable=SC1091 | ||
if [[ -r ~/.fzf.bash ]]; then | ||
source ~/.fzf.bash | ||
elif [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/fzf/fzf.bash" ]]; then | ||
source "${XDG_CONFIG_HOME:-$HOME/.config}/fzf/fzf.bash" | ||
fi | ||
|
||
# No need to continue if the command is not present | ||
_command_exists fzf || return | ||
if ! _binary_exists fzf; then | ||
_log_warning "${BASH_SOURCE[0]##*/}: unable to initialize without '$_' installed." | ||
return 1 | ||
fi | ||
|
||
if [ -z ${FZF_DEFAULT_COMMAND+x} ] && _command_exists fd ; then | ||
export FZF_DEFAULT_COMMAND='fd --type f' | ||
if [[ -z ${FZF_DEFAULT_COMMAND+x} ]] && _command_exists fd; then | ||
export FZF_DEFAULT_COMMAND='fd --type f' | ||
fi | ||
|
||
fe() { | ||
about "Open the selected file in the default editor" | ||
group "fzf" | ||
param "1: Search term" | ||
example "fe foo" | ||
function fe() { | ||
about "Open the selected file in the default editor" | ||
group "fzf" | ||
param "1: Search term" | ||
example "fe foo" | ||
|
||
local IFS=$'\n' | ||
local files | ||
files=($(fzf-tmux --query="$1" --multi --select-1 --exit-0)) | ||
[[ -n "$files" ]] && ${EDITOR:-vim} "${files[@]}" | ||
local IFS=$'\n' | ||
local files | ||
IFS=$'\n' read -ra files < <(fzf-tmux --query="$1" --multi --select-1 --exit-0) | ||
[[ -n "${files[*]}" ]] && "${EDITOR:-${ALTERNATE_EDITOR:-nano}}" "${files[@]}" | ||
} | ||
|
||
fcd() { | ||
about "cd to the selected directory" | ||
group "fzf" | ||
param "1: Directory to browse, or . if omitted" | ||
example "fcd aliases" | ||
function fcd() { | ||
about "cd to the selected directory" | ||
group "fzf" | ||
param "1: Directory to browse, or . if omitted" | ||
example "fcd aliases" | ||
|
||
local dir | ||
dir=$(find ${1:-.} -path '*/\.*' -prune \ | ||
-o -type d -print 2> /dev/null | fzf +m) && | ||
cd "$dir" | ||
local dir | ||
dir=$(find "${1:-.}" -path '*/\.*' -prune \ | ||
-o -type d -print 2> /dev/null | fzf +m) \ | ||
&& cd "$dir" || return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
# shellcheck shell=bash | ||
cite about-plugin | ||
about-plugin 'load hub, if you are using it' | ||
|
||
if _command_exists hub; then | ||
eval "$(hub alias -s)" | ||
if ! _binary_exists hub; then | ||
_log_warning "Unable to locate 'hub'." | ||
fi | ||
|
||
source < <(hub alias -s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
cite about-plugin | ||
# shellcheck shell=bash | ||
about-plugin 'load jenv, if you are using it' | ||
|
||
# Don't modify the environment if we can't find the tool: | ||
# - Check if in $PATH already | ||
# - Check if installed manually to $JENV_ROOT | ||
# - Check if installed manually to $HOME | ||
_command_exists jenv || | ||
[[ -n "$JENV_ROOT" && -x "$JENV_ROOT/bin/jenv" ]] || | ||
[[ -x "$HOME/.jenv/bin/jenv" ]] || | ||
return | ||
if ! _binary_exists jenv && ! [[ -n "${JENV_ROOT:-}" && -x "$JENV_ROOT/bin/jenv" ]] && ! [[ -x "$HOME/.jenv/bin/jenv" ]]; then | ||
_log_warning "Unable to locate 'jenv'." | ||
return 1 | ||
fi | ||
|
||
# Set JENV_ROOT, if not already set | ||
export JENV_ROOT="${JENV_ROOT:-$HOME/.jenv}" | ||
: "${JENV_ROOT:=$HOME/.jenv}" | ||
export JENV_ROOT | ||
|
||
# Add JENV_ROOT/bin to PATH, if that's where it's installed | ||
! _command_exists jenv && | ||
[[ -x "$JENV_ROOT/bin/jenv" ]] && | ||
pathmunge "$JENV_ROOT/bin" | ||
if ! _command_exists jenv && [[ -x "$JENV_ROOT/bin/jenv" ]]; then | ||
pathmunge "$JENV_ROOT/bin" | ||
fi | ||
|
||
# Initialize jenv | ||
eval "$(jenv init - bash)" | ||
# shellcheck disable=SC1090 # Initialize jenv | ||
source < <(jenv init - bash) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
# shellcheck shell=bash | ||
cite about-plugin | ||
about-plugin 'Node.js helper functions' | ||
|
||
# Check that we have npm | ||
_command_exists npm || return | ||
if ! _binary_exists npm; then | ||
_log_warning "Unable to locage 'npm'." | ||
return 1 | ||
fi | ||
|
||
# Ensure local modules are preferred in PATH | ||
pathmunge "./node_modules/.bin" "after" | ||
|
||
# If not using nodenv, ensure global modules are in PATH | ||
if [[ ! "$(type -p npm)" == *"nodenv/shims"* ]]; then | ||
if [[ "$(type -p npm)" != *"nodenv/shims"* ]]; then | ||
pathmunge "$(npm config get prefix)/bin" "after" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
# shellcheck shell=bash | ||
cite about-plugin | ||
about-plugin 'load nodenv, if you are using it' | ||
|
||
export NODENV_ROOT="$HOME/.nodenv" | ||
pathmunge "$NODENV_ROOT/bin" | ||
if [[ -d "${NODENV_ROOT:=$HOME/.nodenv}/bin" ]]; then | ||
export NODENV_ROOT | ||
pathmunge "$NODENV_ROOT/bin" | ||
fi | ||
|
||
if _command_exists nodenv; then | ||
eval "$(nodenv init - bash)" | ||
if ! _binary_exists nodenv; then | ||
_log_warning "Unable to locage 'nodenv'." | ||
fi | ||
|
||
# shellcheck disable=SC1090 | ||
source < <(nodenv init - bash) |
Oops, something went wrong.