-
-
Notifications
You must be signed in to change notification settings - Fork 108
/
init.sh
61 lines (53 loc) · 1.78 KB
/
init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# vim: ft=zsh
export ENHANCD_ROOT
export ENHANCD_COMMAND
export ENHANCD_FILTER
export ENHANCD_DIR="${ENHANCD_DIR:-$HOME/.enhancd}"
export ENHANCD_ENABLE_DOUBLE_DOT="${ENHANCD_ENABLE_DOUBLE_DOT:-true}"
export ENHANCD_ENABLE_SINGLE_DOT=${ENHANCD_ENABLE_SINGLE_DOT:-true}
export ENHANCD_ENABLE_HYPHEN="${ENHANCD_ENABLE_HYPHEN:-true}"
export ENHANCD_ENABLE_HOME="${ENHANCD_ENABLE_HOME:-true}"
export ENHANCD_ARG_DOUBLE_DOT="${ENHANCD_ARG_DOUBLE_DOT:-..}"
export ENHANCD_ARG_SINGLE_DOT="${ENHANCD_ARG_SINGLE_DOT:-.}"
export ENHANCD_ARG_HYPHEN="${ENHANCD_ARG_HYPHEN:--}"
export ENHANCD_ARG_HOME="${ENHANCD_ARG_HOME:-}"
export ENHANCD_HYPHEN_NUM="${ENHANCD_HYPHEN_NUM:-10}"
export ENHANCD_COMPLETION_DEFAULT
export ENHANCD_COMPLETION_KEYBIND="${ENHANCD_COMPLETION_KEYBIND:-^I}"
export ENHANCD_COMPLETION_BEHAVIOR="${ENHANCD_COMPLETION_BEHAVIOR:-default}"
export ENHANCD_USE_ABBREV="${ENHANCD_USE_ABBREV:-false}"
if [[ -n ${BASH_VERSION} ]]; then
# BASH
ENHANCD_ROOT="$(builtin cd "$(command dirname "${BASH_SOURCE}")" && pwd)"
elif [[ -n ${ZSH_VERSION} ]]; then
# ZSH
ENHANCD_ROOT="${${(%):-%x}:A:h}"
compdef _cd __enhancd::cd
fi
export _ENHANCD_VERSION="$(command cat "${ENHANCD_ROOT}/VERSION" 2>/dev/null)"
# core files
for src in ${ENHANCD_ROOT}/src/*.sh
do
source "${src}"
done
# custom sources
if [[ -d ${ENHANCD_DIR}/sources ]]; then
for src in $(command find "${ENHANCD_DIR}/sources" -name "*\.sh")
do
source "${src}"
done
fi
# make a log file and a root directory
if [[ ! -d ${ENHANCD_DIR} ]]; then
mkdir -p "${ENHANCD_DIR}"
fi
if [[ ! -f ${ENHANCD_DIR}/enhancd.log ]]; then
touch "${ENHANCD_DIR}/enhancd.log"
fi
# alias to cd
eval "alias ${ENHANCD_COMMAND:=cd}=__enhancd::cd"
# Set the filter if empty
if [[ -z ${ENHANCD_FILTER} ]]; then
ENHANCD_FILTER="fzy:fzf:peco:sk:zf"
fi