mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
put the autojump data files in the correct directories.
Existing files should be migrated automatically
This commit is contained in:
parent
6bcd8259a5
commit
4de9c1c311
6
autojump
6
autojump
@ -24,6 +24,7 @@ import signal
|
||||
max_keyweight=1000
|
||||
max_stored_paths=400
|
||||
completion_separator='__'
|
||||
config_dir=os.environ.get("AUTOJUMP_DATA_DIR",os.path.expanduser("~"))
|
||||
|
||||
def signal_handler(arg1,arg2):
|
||||
print "Received SIGINT, trying to continue"
|
||||
@ -123,7 +124,10 @@ except getopt.GetoptError, e:
|
||||
print "Unknown command line argument: %s" % e
|
||||
exit(1)
|
||||
|
||||
dic_file=os.path.expanduser("~/.autojump_py")
|
||||
if config_dir == os.path.expanduser("~"):
|
||||
dic_file=config_dir+"/.autojump_py"
|
||||
else:
|
||||
dic_file=config_dir+"/autojump_py"
|
||||
path_dict=open_dic(dic_file)
|
||||
if ('-a','') in optlist:
|
||||
if(args[-1] != os.path.expanduser("~")): # home dir can be reached quickly by "cd" and may interfere with other directories
|
||||
|
@ -25,7 +25,22 @@ _autojump()
|
||||
done < <(autojump --bash --completion $cur)
|
||||
}
|
||||
complete -F _autojump j
|
||||
AUTOJUMP='{ (autojump -a "$(pwd -P)"&)>/dev/null 2>>${HOME}/.autojump_errors;} 2>/dev/null'
|
||||
data_dir=${XDG_DATA_DIR:-$([ -e ~/.config ] && echo ~/.config || echo ~)}
|
||||
if [ "$data_dir" = "~" ]
|
||||
then
|
||||
export AUTOJUMP_DATA_DIR=${data_dir}
|
||||
else
|
||||
export AUTOJUMP_DATA_DIR=${data_dir}/autojump
|
||||
fi
|
||||
if [ ! -e "${AUTOJUMP_DATA_DIR}" ]
|
||||
then
|
||||
mkdir "${AUTOJUMP_DATA_DIR}"
|
||||
mv ~/.autojump_py "${AUTOJUMP_DATA_DIR}/autojump_py" 2>>/dev/null #migration
|
||||
mv ~/.autojump_py.bak "${AUTOJUMP_DATA_DIR}/autojump_py.bak" 2>>/dev/null
|
||||
mv ~/.autojump_errors "${AUTOJUMP_DATA_DIR}/autojump_errors" 2>>/dev/null
|
||||
fi
|
||||
|
||||
AUTOJUMP='{ (autojump -a "$(pwd -P)"&)>/dev/null 2>>${AUTOJUMP_DATA_DIR}/.autojump_errors;} 2>/dev/null'
|
||||
if [[ ! $PROMPT_COMMAND =~ autojump ]]; then
|
||||
export PROMPT_COMMAND="${PROMPT_COMMAND:-:} && $AUTOJUMP"
|
||||
fi
|
||||
|
17
autojump.zsh
17
autojump.zsh
@ -14,8 +14,23 @@
|
||||
#You should have received a copy of the GNU General Public License
|
||||
#along with autojump. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
data_dir=${XDG_DATA_DIR:-$([ -e ~/.config ] && echo ~/.config || echo ~)}
|
||||
if [ "$data_dir" = "~" ]
|
||||
then
|
||||
export AUTOJUMP_DATA_DIR=${data_dir}
|
||||
else
|
||||
export AUTOJUMP_DATA_DIR=${data_dir}/autojump
|
||||
fi
|
||||
if [ ! -e "${AUTOJUMP_DATA_DIR}" ]
|
||||
then
|
||||
mkdir "${AUTOJUMP_DATA_DIR}"
|
||||
mv ~/.autojump_py "${AUTOJUMP_DATA_DIR}/autojump_py" 2>>/dev/null #migration
|
||||
mv ~/.autojump_py.bak "${AUTOJUMP_DATA_DIR}/autojump_py.bak" 2>>/dev/null
|
||||
mv ~/.autojump_errors "${AUTOJUMP_DATA_DIR}/autojump_errors" 2>>/dev/null
|
||||
fi
|
||||
|
||||
function autojump_preexec() {
|
||||
{ (autojump -a "$(pwd -P)"&)>/dev/null 2>>|${HOME}/.autojump_errors ; } 2>/dev/null
|
||||
{ (autojump -a "$(pwd -P)"&)>/dev/null 2>>|${AUTOJUMP_DATA_DIR}/.autojump_errors ; } 2>/dev/null
|
||||
}
|
||||
|
||||
typeset -ga preexec_functions
|
||||
|
Loading…
Reference in New Issue
Block a user