mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
quick fix so thant it works on mingw and bash 3.1
This commit is contained in:
parent
a4f4472046
commit
a6410994c2
35
autojump
35
autojump
@ -55,23 +55,24 @@ def save(path_dict, dic_file):
|
|||||||
a backup file."""
|
a backup file."""
|
||||||
# If the dic_file exists, check that it belongs to us
|
# If the dic_file exists, check that it belongs to us
|
||||||
# Otherwise, fail quietly
|
# Otherwise, fail quietly
|
||||||
if (not os.path.exists(dic_file)) or os.getuid() == os.stat(dic_file)[4]:
|
temp = NamedTemporaryFile(dir=CONFIG_DIR, delete=False)
|
||||||
temp = NamedTemporaryFile(dir=CONFIG_DIR, delete=False)
|
pickle.dump(path_dict, temp, 2)
|
||||||
pickle.dump(path_dict, temp, 2)
|
temp.flush()
|
||||||
temp.flush()
|
os.fsync(temp)
|
||||||
os.fsync(temp)
|
temp.close()
|
||||||
temp.close()
|
#cf. http://thunk.org/tytso/blog/2009/03/15/dont-fear-the-fsync/
|
||||||
#cf. http://thunk.org/tytso/blog/2009/03/15/dont-fear-the-fsync/
|
#os.rename(temp.name, dic_file)
|
||||||
os.rename(temp.name, dic_file)
|
import shutil
|
||||||
try: #backup file
|
shutil.copy(temp.name, dic_file)
|
||||||
import time
|
try: #backup file
|
||||||
if (not os.path.exists(dic_file+".bak") or
|
import time
|
||||||
time.time()-os.path.getmtime(dic_file+".bak")>86400):
|
if (not os.path.exists(dic_file+".bak") or
|
||||||
import shutil
|
time.time()-os.path.getmtime(dic_file+".bak")>86400):
|
||||||
shutil.copy(dic_file, dic_file+".bak")
|
import shutil
|
||||||
except OSError as ex:
|
shutil.copy(dic_file, dic_file+".bak")
|
||||||
print("Error while creating backup autojump file. (%s)" %
|
except OSError as ex:
|
||||||
ex, file=stderr)
|
print("Error while creating backup autojump file. (%s)" %
|
||||||
|
ex, file=stderr)
|
||||||
|
|
||||||
def forget(path_dict, dic_file):
|
def forget(path_dict, dic_file):
|
||||||
"""Gradually forget about directories. Only call
|
"""Gradually forget about directories. Only call
|
||||||
|
@ -19,10 +19,11 @@ _autojump()
|
|||||||
{
|
{
|
||||||
local cur
|
local cur
|
||||||
cur=${COMP_WORDS[*]:1}
|
cur=${COMP_WORDS[*]:1}
|
||||||
while read i
|
comps=$(autojump --bash --completion $cur)
|
||||||
|
for i in $comps
|
||||||
do
|
do
|
||||||
COMPREPLY=("${COMPREPLY[@]}" "${i}")
|
COMPREPLY=("${COMPREPLY[@]}" "${i}")
|
||||||
done < <(autojump --bash --completion $cur)
|
done
|
||||||
}
|
}
|
||||||
complete -F _autojump j
|
complete -F _autojump j
|
||||||
|
|
||||||
@ -43,9 +44,12 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
export AUTOJUMP_HOME=${HOME}
|
export AUTOJUMP_HOME=${HOME}
|
||||||
AUTOJUMP='{ [[ "$AUTOJUMP_HOME" == "$HOME" ]] && (autojump -a "$(pwd -P)"&)>/dev/null 2>>${AUTOJUMP_DATA_DIR}/.autojump_errors;} 2>/dev/null'
|
AUTOJUMP='{ [[ "$AUTOJUMP_HOME" == "$HOME" ]] && (autojump -a "$(pwd -P)"&)>/dev/null 2>>"${AUTOJUMP_DATA_DIR}/.autojump_errors";} 2>/dev/null'
|
||||||
if [[ ! $PROMPT_COMMAND =~ autojump ]]; then
|
|
||||||
export PROMPT_COMMAND="$AUTOJUMP ; ${PROMPT_COMMAND:-:}"
|
case $PROMPT_COMMAND in
|
||||||
fi
|
*autojump*) ;;
|
||||||
|
*) export PROMPT_COMMAND="$AUTOJUMP ; ${PROMPT_COMMAND:-:}";;
|
||||||
|
esac
|
||||||
|
|
||||||
alias jumpstat="autojump --stat"
|
alias jumpstat="autojump --stat"
|
||||||
function j { new_path="$(autojump $@)";if [ -n "$new_path" ]; then echo -e "\\033[31m${new_path}\\033[0m"; cd "$new_path";else false; fi }
|
function j { new_path="$(autojump --bash $@)";if [ -n "$new_path" ]; then echo -e "\\033[31m${new_path}\\033[0m"; cd "$new_path";else false; fi }
|
||||||
|
20
install.sh
20
install.sh
@ -16,7 +16,7 @@
|
|||||||
#along with autojump. If not, see <http://www.gnu.org/licenses/>.
|
#along with autojump. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
function show_help {
|
function show_help {
|
||||||
echo "sudo ./install.sh [--prefix /usr/local]"
|
echo " ./install.sh [--prefix /usr/local]"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Default install directory.
|
# Default install directory.
|
||||||
@ -41,17 +41,17 @@ done
|
|||||||
echo "Installing to ${prefix} ..."
|
echo "Installing to ${prefix} ..."
|
||||||
|
|
||||||
# INSTALL AUTOJUMP
|
# INSTALL AUTOJUMP
|
||||||
sudo mkdir -p ${prefix}/share/autojump/
|
mkdir -p ${prefix}/share/autojump/
|
||||||
sudo mkdir -p ${prefix}/bin/
|
mkdir -p ${prefix}/bin/
|
||||||
sudo mkdir -p ${prefix}/share/man/man1/
|
mkdir -p ${prefix}/share/man/man1/
|
||||||
sudo cp icon.png ${prefix}/share/autojump/
|
cp icon.png ${prefix}/share/autojump/
|
||||||
sudo cp jumpapplet ${prefix}/bin/
|
cp jumpapplet ${prefix}/bin/
|
||||||
sudo cp autojump ${prefix}/bin/
|
cp autojump ${prefix}/bin/
|
||||||
sudo cp autojump.1 ${prefix}/share/man/man1/
|
cp autojump.1 ${prefix}/share/man/man1/
|
||||||
|
|
||||||
if [ -d "/etc/profile.d" ]; then
|
if [ -d "/etc/profile.d" ]; then
|
||||||
sudo cp autojump.bash /etc/profile.d/
|
cp autojump.bash /etc/profile.d/
|
||||||
sudo cp autojump.sh /etc/profile.d/
|
cp autojump.sh /etc/profile.d/
|
||||||
|
|
||||||
# Make sure that the code we just copied has been sourced.
|
# Make sure that the code we just copied has been sourced.
|
||||||
# check if .bashrc has sourced /etc/profile or /etc/profile.d/autojump.bash
|
# check if .bashrc has sourced /etc/profile or /etc/profile.d/autojump.bash
|
||||||
|
Loading…
Reference in New Issue
Block a user