cleanup autojump.bash

pull/252/head
William Ting 11 years ago
parent 6293af5b7a
commit 9811922a77

@ -1,7 +1,7 @@
_autojump() { _autojump() {
local cur local cur
cur=${COMP_WORDS[*]:1} cur=${COMP_WORDS[*]:1}
comps=$(autojump --bash --complete $cur) comps=$(autojump --complete $cur)
while read i while read i
do do
COMPREPLY=("${COMPREPLY[@]}" "${i}") COMPREPLY=("${COMPREPLY[@]}" "${i}")
@ -16,7 +16,7 @@ _autojump_files() {
local cur local cur
#cur=${COMP_WORDS[*]:1} #cur=${COMP_WORDS[*]:1}
cur=${COMP_WORDS[COMP_CWORD]} cur=${COMP_WORDS[COMP_CWORD]}
comps=$(autojump --bash --complete $cur) comps=$(autojump --complete $cur)
while read i while read i
do do
COMPREPLY=("${COMPREPLY[@]}" "${i}") COMPREPLY=("${COMPREPLY[@]}" "${i}")
@ -30,33 +30,13 @@ if [[ -n ${AUTOJUMP_AUTOCOMPLETE_CMDS} ]]; then
complete -o default -o bashdefault -F _autojump_files ${AUTOJUMP_AUTOCOMPLETE_CMDS} complete -o default -o bashdefault -F _autojump_files ${AUTOJUMP_AUTOCOMPLETE_CMDS}
fi fi
#determine the data directory according to the XDG Base Directory Specification
if [[ -n ${XDG_DATA_HOME} ]] && [[ ${XDG_DATA_HOME} =~ ${USER} ]]; then
export AUTOJUMP_DATA_DIR="${XDG_DATA_HOME}/autojump"
else
export AUTOJUMP_DATA_DIR=~/.local/share/autojump
fi
if [ ! -e "${AUTOJUMP_DATA_DIR}" ]; then
mkdir -p "${AUTOJUMP_DATA_DIR}"
fi
# set paths if necessary for local installations # set paths if necessary for local installations
if [ -d ~/.autojump/ ]; then if [ -d ~/.autojump/ ]; then
export PATH=~/.autojump/bin:"${PATH}" export PATH=~/.autojump/bin:"${PATH}"
fi fi
export AUTOJUMP_HOME=${HOME}
if [ "${AUTOJUMP_KEEP_SYMLINKS}" == "1" ]; then
_PWD_ARGS=""
else
_PWD_ARGS="-P"
fi
autojump_add_to_database() { autojump_add_to_database() {
if [[ "${AUTOJUMP_HOME}" == "${HOME}" ]]; then autojump -a "$(pwd)" &>/dev/null
autojump -a "$(pwd ${_PWD_ARGS})" 1>/dev/null 2>>"${AUTOJUMP_DATA_DIR}/autojump_errors"
fi
} }
case $PROMPT_COMMAND in case $PROMPT_COMMAND in
@ -86,7 +66,7 @@ j() {
jc() { jc() {
if [[ ${@} == -* ]]; then if [[ ${@} == -* ]]; then
j ${@} autojump ${@}
else else
j $(pwd)/ ${@} j $(pwd)/ ${@}
fi fi
@ -117,7 +97,7 @@ jo() {
jco() { jco() {
if [[ ${@} == -* ]]; then if [[ ${@} == -* ]]; then
j ${@} autojump ${@}
else else
jo $(pwd) ${@} jo $(pwd) ${@}
fi fi

@ -39,33 +39,31 @@ j() {
jc() { jc() {
if [[ ${@} == -* ]]; then if [[ ${@} == -* ]]; then
autojump ${@} autojump ${@}
return else
j $(pwd)/ ${@}
fi fi
j $(pwd)/ ${@}
} }
# open autojump results in file browser # open autojump results in file browser
jo() { jo() {
if [[ ${@} == -* ]]; then if [[ ${@} == -* ]]; then
autojump ${@} autojump ${@}
return else
case ${OSTYPE} in
linux-gnu)
xdg-open "$(autojump $@)"
;;
darwin*)
open "$(autojump $@)"
;;
cygwin)
cygstart "" $(cygpath -w -a $(pwd))
;;
*)
echo "Unknown operating system." 1>&2
;;
esac
fi fi
case ${OSTYPE} in
linux-gnu)
xdg-open "$(autojump $@)"
;;
darwin*)
open "$(autojump $@)"
;;
cygwin)
cygstart "" $(cygpath -w -a $(pwd))
;;
*)
echo "Unknown operating system." 1>&2
;;
esac
} }
# open autojump results (child directory) in file browser # open autojump results (child directory) in file browser

@ -20,7 +20,7 @@ def cp(src, dest, dryrun=False):
def get_shell(): def get_shell():
return os.path.basename(os.getenv('SHELL')) return os.path.basename(os.getenv('SHELL', ''))
def mkdir(path, dryrun=False): def mkdir(path, dryrun=False):

Loading…
Cancel
Save