39 lines
1.0 KiB
Bash
39 lines
1.0 KiB
Bash
# Bash-only interactive shell helpers.
|
|
[[ -n ${BASH_VERSION:-} ]] || return 0
|
|
|
|
DOTFILE_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
|
|
|
|
export EDITOR='vim'
|
|
export VISUAL="$EDITOR"
|
|
case ":$PATH:" in
|
|
*":$HOME/.local/bin:"*) ;;
|
|
*) export PATH="$PATH:$HOME/.local/bin" ;;
|
|
esac
|
|
|
|
# shellcheck source=bash_tools/theme_bash.sh
|
|
source "$DOTFILE_DIR/bash_tools/theme_bash.sh"
|
|
# shellcheck source=bash_tools/ls_colors_theme.sh
|
|
source "$DOTFILE_DIR/bash_tools/ls_colors_theme.sh"
|
|
|
|
if ls --color=auto -d . >/dev/null 2>&1; then
|
|
alias ls='ls --color=auto'
|
|
elif [[ $OSTYPE == darwin* ]]; then
|
|
alias ls='ls -G'
|
|
fi
|
|
|
|
# Search for a literal string. Usage: fct <directory> <text>
|
|
fct() {
|
|
(($# == 2)) || { printf 'Usage: fct <directory> <text>\n' >&2; return 2; }
|
|
if command -v rg >/dev/null 2>&1; then
|
|
rg -n --fixed-strings -- "$2" "$1"
|
|
else
|
|
grep -Rnw -- "$1" -e "$2"
|
|
fi
|
|
}
|
|
|
|
# Query dict.org. Usage: odict <word>
|
|
odict() {
|
|
(($# == 1)) || { printf 'Usage: odict <word>\n' >&2; return 2; }
|
|
curl --fail --silent --show-error "dict://dict.org/d:$1"
|
|
}
|