From 48386d477c3e83d47fb6a177824e178c21437201 Mon Sep 17 00:00:00 2001 From: satoru Date: Tue, 1 Dec 2020 07:33:10 +0800 Subject: [PATCH] Fix #4: replace autojump with shonenjump --- scripts/shonenjump.bash | 54 ++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/scripts/shonenjump.bash b/scripts/shonenjump.bash index a7c8fdd..a1a2205 100644 --- a/scripts/shonenjump.bash +++ b/scripts/shonenjump.bash @@ -1,18 +1,12 @@ export AUTOJUMP_SOURCED=1 -# set user installation paths -if [[ -d ~/.autojump/ ]]; then - export PATH=~/.autojump/bin:"${PATH}" -fi - - # set error file location if [[ "$(uname)" == "Darwin" ]]; then - export AUTOJUMP_ERROR_PATH=~/Library/autojump/errors.log + export AUTOJUMP_ERROR_PATH=~/Library/shonenjump/errors.log elif [[ -n "${XDG_DATA_HOME}" ]]; then - export AUTOJUMP_ERROR_PATH="${XDG_DATA_HOME}/autojump/errors.log" + export AUTOJUMP_ERROR_PATH="${XDG_DATA_HOME}/shonenjump/errors.log" else - export AUTOJUMP_ERROR_PATH=~/.local/share/autojump/errors.log + export AUTOJUMP_ERROR_PATH=~/.local/share/shonenjump/errors.log fi if [[ ! -d "$(dirname ${AUTOJUMP_ERROR_PATH})" ]]; then @@ -21,45 +15,45 @@ fi # enable tab completion -_autojump() { +_shonenjump() { local cur cur=${COMP_WORDS[*]:1} - comps=$(autojump --complete $cur) + comps=$(shonenjump --complete $cur) while read i; do COMPREPLY=("${COMPREPLY[@]}" "${i}") done </dev/null 2>>${AUTOJUMP_ERROR_PATH} &) &>/dev/null + (shonenjump --add "$(pwd)" >/dev/null 2>>${AUTOJUMP_ERROR_PATH} &) &>/dev/null else - (autojump --add "$(pwd)" >/dev/null &) &>/dev/null + (shonenjump --add "$(pwd)" >/dev/null &) &>/dev/null fi } case $PROMPT_COMMAND in - *autojump*) + *shonenjump*) ;; *) - PROMPT_COMMAND="${PROMPT_COMMAND:+$(echo "${PROMPT_COMMAND}" | awk '{gsub(/; *$/,"")}1') ; }autojump_add_to_database" + PROMPT_COMMAND="${PROMPT_COMMAND:+$(echo "${PROMPT_COMMAND}" | awk '{gsub(/; *$/,"")}1') ; }shonenjump_add_to_database" ;; esac -# default autojump command +# default shonenjump command j() { if [[ ${1} == -* ]] && [[ ${1} != "--" ]]; then - autojump ${@} + shonenjump ${@} return fi - output="$(autojump ${@})" + output="$(shonenjump ${@})" if [[ -d "${output}" ]]; then if [ -t 1 ]; then # if stdout is a terminal, use colors echo -e "\\033[31m${output}\\033[0m" @@ -68,9 +62,9 @@ j() { fi cd "${output}" else - echo "autojump: directory '${@}' not found" + echo "shonenjump: directory '${@}' not found" echo "\n${output}\n" - echo "Try \`autojump --help\` for more information." + echo "Try \`shonenjump --help\` for more information." false fi } @@ -79,7 +73,7 @@ j() { # jump to child directory (subdirectory of current path) jc() { if [[ ${1} == -* ]] && [[ ${1} != "--" ]]; then - autojump ${@} + shonenjump ${@} return else j $(pwd) ${@} @@ -87,14 +81,14 @@ jc() { } -# open autojump results in file browser +# open shonenjump results in file browser jo() { if [[ ${1} == -* ]] && [[ ${1} != "--" ]]; then - autojump ${@} + shonenjump ${@} return fi - output="$(autojump ${@})" + output="$(shonenjump ${@})" if [[ -d "${output}" ]]; then case ${OSTYPE} in linux*) @@ -111,18 +105,18 @@ jo() { ;; esac else - echo "autojump: directory '${@}' not found" + echo "shonenjump: directory '${@}' not found" echo "\n${output}\n" - echo "Try \`autojump --help\` for more information." + echo "Try \`shonenjump --help\` for more information." false fi } -# open autojump results (child directory) in file browser +# open shonenjump results (child directory) in file browser jco() { if [[ ${1} == -* ]] && [[ ${1} != "--" ]]; then - autojump ${@} + shonenjump ${@} return else jo $(pwd) ${@}