mirror of https://github.com/wting/autojump
Merge 0883bf60aa
into ff75f542ae
commit
2bee71df0b
@ -1,17 +1,15 @@
|
|||||||
language: python
|
language: python
|
||||||
|
|
||||||
python: 2.7
|
python:
|
||||||
|
- 2.7
|
||||||
env:
|
- 3.3
|
||||||
- TOX_ENV=py26
|
- 3.4
|
||||||
- TOX_ENV=py27
|
- 3.5
|
||||||
- TOX_ENV=py32
|
- 3.6
|
||||||
- TOX_ENV=py33
|
|
||||||
- TOX_ENV=py34
|
|
||||||
- TOX_ENV=flake8
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- pip install tox
|
- pip install mock coverage ipdb ipython pytest pre-commit autopep8 flake8
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- tox -e $TOX_ENV
|
- coverage run --source=bin/ --omit=bin/autojump_argparse.py -m py.test -vv -rxs --tb native -s --strict
|
||||||
|
- coverage report -m
|
||||||
|
@ -1,130 +1,140 @@
|
|||||||
export AUTOJUMP_SOURCED=1
|
if [[ -z $AUTOJUMP_SOURCED ]]; then
|
||||||
|
export AUTOJUMP_SOURCED=1
|
||||||
|
|
||||||
# set user installation paths
|
# Script include
|
||||||
if [[ -d ~/.autojump/ ]]; then
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
export PATH=~/.autojump/bin:"${PATH}"
|
|
||||||
fi
|
# set user installation paths
|
||||||
|
export PATH="${SCRIPT_DIR}:${PATH}"
|
||||||
|
|
||||||
|
|
||||||
# set error file location
|
# set error file location
|
||||||
if [[ "$(uname)" == "Darwin" ]]; then
|
if [[ "$(uname)" == "Darwin" ]]; then
|
||||||
export AUTOJUMP_ERROR_PATH=~/Library/autojump/errors.log
|
export AUTOJUMP_ERROR_PATH=~/Library/autojump/errors.log
|
||||||
elif [[ -n "${XDG_DATA_HOME}" ]]; then
|
elif [[ -n "${XDG_DATA_HOME}" ]]; then
|
||||||
export AUTOJUMP_ERROR_PATH="${XDG_DATA_HOME}/autojump/errors.log"
|
export AUTOJUMP_ERROR_PATH="${XDG_DATA_HOME}/autojump/errors.log"
|
||||||
else
|
else
|
||||||
export AUTOJUMP_ERROR_PATH=~/.local/share/autojump/errors.log
|
export AUTOJUMP_ERROR_PATH=~/.local/share/autojump/errors.log
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -d "$(dirname ${AUTOJUMP_ERROR_PATH})" ]]; then
|
if [[ ! -d "$(dirname ${AUTOJUMP_ERROR_PATH})" ]]; then
|
||||||
mkdir -p "$(dirname ${AUTOJUMP_ERROR_PATH})"
|
mkdir -p "$(dirname ${AUTOJUMP_ERROR_PATH})"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# enable tab completion
|
# enable tab completion
|
||||||
_autojump() {
|
_autojump() {
|
||||||
local cur
|
local cur
|
||||||
cur=${COMP_WORDS[*]:1}
|
cur=${COMP_WORDS[*]:1}
|
||||||
comps=$(autojump --complete $cur)
|
comps=$(autojump --complete $cur)
|
||||||
while read i; do
|
echo "$comps" | while read i; do
|
||||||
COMPREPLY=("${COMPREPLY[@]}" "${i}")
|
COMPREPLY=("${COMPREPLY[@]}" "${i}")
|
||||||
done <<EOF
|
done
|
||||||
$comps
|
}
|
||||||
EOF
|
complete -F _autojump j
|
||||||
}
|
|
||||||
complete -F _autojump j
|
|
||||||
|
|
||||||
|
|
||||||
# change pwd hook
|
# change pwd hook
|
||||||
autojump_add_to_database() {
|
autojump_add_to_database() {
|
||||||
if [[ -f "${AUTOJUMP_ERROR_PATH}" ]]; then
|
if [[ -f "${AUTOJUMP_ERROR_PATH}" ]]; then
|
||||||
(autojump --add "$(pwd)" >/dev/null 2>>${AUTOJUMP_ERROR_PATH} &) &>/dev/null
|
(autojump --add "$(pwd)" >/dev/null 2>>${AUTOJUMP_ERROR_PATH} &) &>/dev/null
|
||||||
else
|
else
|
||||||
(autojump --add "$(pwd)" >/dev/null &) &>/dev/null
|
(autojump --add "$(pwd)" >/dev/null &) &>/dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
case $PROMPT_COMMAND in
|
case $PROMPT_COMMAND in
|
||||||
*autojump*)
|
*autojump*)
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
PROMPT_COMMAND="${PROMPT_COMMAND:+$(echo "${PROMPT_COMMAND}" | awk '{gsub(/; *$/,"")}1') ; }autojump_add_to_database"
|
PROMPT_COMMAND="${PROMPT_COMMAND:+$(echo "${PROMPT_COMMAND}" | awk '{gsub(/; *$/,"")}1') ; }autojump_add_to_database"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
# default autojump command
|
# default autojump command
|
||||||
j() {
|
j() {
|
||||||
if [[ ${1} == -* ]] && [[ ${1} != "--" ]]; then
|
if [[ ${1} == -* ]] && [[ ${1} != "--" ]]; then
|
||||||
autojump ${@}
|
autojump ${@}
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
output="$(autojump ${@})"
|
output="$(autojump ${@})"
|
||||||
if [[ -d "${output}" ]]; then
|
if [[ -d "${output}" ]]; then
|
||||||
if [ -t 1 ]; then # if stdout is a terminal, use colors
|
if [ -t 1 ]; then # if stdout is a terminal, use colors
|
||||||
echo -e "\\033[31m${output}\\033[0m"
|
echo -e "\\033[31m${output}\\033[0m"
|
||||||
else
|
else
|
||||||
echo -e "${output}"
|
echo -e "${output}"
|
||||||
fi
|
fi
|
||||||
cd "${output}"
|
cd "${output}"
|
||||||
else
|
else
|
||||||
echo "autojump: directory '${@}' not found"
|
echo "autojump: directory '${@}' not found"
|
||||||
echo "\n${output}\n"
|
echo "\n${output}\n"
|
||||||
echo "Try \`autojump --help\` for more information."
|
echo "Try \`autojump --help\` for more information."
|
||||||
false
|
false
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# jump to child directory (subdirectory of current path)
|
# jump to child directory (subdirectory of current path)
|
||||||
jc() {
|
jc() {
|
||||||
if [[ ${1} == -* ]] && [[ ${1} != "--" ]]; then
|
if [[ ${1} == -* ]] && [[ ${1} != "--" ]]; then
|
||||||
autojump ${@}
|
autojump ${@}
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
j $(pwd) ${@}
|
j $(pwd) ${@}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# open autojump results in file browser
|
# open autojump results in file browser
|
||||||
jo() {
|
jo() {
|
||||||
if [[ ${1} == -* ]] && [[ ${1} != "--" ]]; then
|
if [[ ${1} == -* ]] && [[ ${1} != "--" ]]; then
|
||||||
autojump ${@}
|
autojump ${@}
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
output="$(autojump ${@})"
|
output="$(autojump ${@})"
|
||||||
if [[ -d "${output}" ]]; then
|
if [[ -d "${output}" ]]; then
|
||||||
case ${OSTYPE} in
|
case ${OSTYPE} in
|
||||||
linux*)
|
linux*)
|
||||||
xdg-open "${output}"
|
xdg-open "${output}"
|
||||||
;;
|
;;
|
||||||
darwin*)
|
darwin*)
|
||||||
open "${output}"
|
open "${output}"
|
||||||
;;
|
;;
|
||||||
cygwin)
|
cygwin)
|
||||||
cygstart "" $(cygpath -w -a ${output})
|
cygstart "" $(cygpath -w -a ${output})
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown operating system: ${OSTYPE}." 1>&2
|
echo "Unknown operating system: ${OSTYPE}." 1>&2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
echo "autojump: directory '${@}' not found"
|
echo "autojump: directory '${@}' not found"
|
||||||
echo "\n${output}\n"
|
echo "\n${output}\n"
|
||||||
echo "Try \`autojump --help\` for more information."
|
echo "Try \`autojump --help\` for more information."
|
||||||
false
|
false
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# open autojump results (child directory) in file browser
|
# open autojump results (child directory) in file browser
|
||||||
jco() {
|
jco() {
|
||||||
if [[ ${1} == -* ]] && [[ ${1} != "--" ]]; then
|
if [[ ${1} == -* ]] && [[ ${1} != "--" ]]; then
|
||||||
autojump ${@}
|
autojump ${@}
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
jo $(pwd) ${@}
|
jo $(pwd) ${@}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Jump around a git repo
|
||||||
|
g() {
|
||||||
|
REPO_ROOT=`git rev-parse --show-toplevel`
|
||||||
|
j "$REPO_ROOT" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "ERROR: autojump was sourced twice"
|
||||||
|
fi
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
Set-Alias -Name ll -Value ls
|
||||||
|
Function .. {cd ..}
|
||||||
|
Function ... {cd ../..}
|
||||||
|
Function .... {cd ../../..}
|
||||||
|
Function ..... {cd ../../../..}
|
||||||
|
Function ...... {cd ../../../../..}
|
||||||
|
Function ....... {cd ../../../../../..}
|
||||||
|
Function ........ {cd ../../../../../../..}
|
||||||
|
Function ......... {cd ../../../../../../../..}
|
||||||
|
Function .......... {cd ../../../../../../../../..}
|
||||||
|
|
||||||
|
Function j {
|
||||||
|
$jumpdir = autojump $args
|
||||||
|
echo "$jumpdir"
|
||||||
|
cd $jumpdir
|
||||||
|
}
|
||||||
|
|
||||||
|
Function jc {
|
||||||
|
j "$pwd" @args
|
||||||
|
}
|
||||||
|
|
||||||
|
Function g {
|
||||||
|
$repo_root = git rev-parse --show-toplevel
|
||||||
|
j $repo_root @args
|
||||||
|
}
|
||||||
|
|
||||||
|
Set-PSBreakpoint -Variable pwd -Mode Write -Action {
|
||||||
|
autojump --add "$pwd"
|
||||||
|
} | out-null
|
Loading…
Reference in new issue