1
0
mirror of https://github.com/wting/autojump synced 2024-10-27 20:34:07 +00:00

Merge commit 'simon/master'

This commit is contained in:
elcerdo 2009-03-31 23:18:58 +02:00
commit dc4c63c9ea
6 changed files with 69 additions and 7 deletions

View File

@ -62,20 +62,25 @@ run::
./install.sh
or::
./install.zsh
depending on your shell.
Enter your root password if it asks.
Add the line::
source /etc/profile
to ``~/.bashrc`` if it isn't already there.
to ``~/.bashrc`` or ``~/.zshrc`` if it isn't already there.
Troubleshoot
------------
If the script fails, you may need to do::
chmod +x install.sh
chmod +x install.(z)sh
before the first step.
@ -86,7 +91,7 @@ Manual installation of autojump is very simple: copy
- autojump.sh to /etc/profile.d,
- autojump.1 to /usr/share/man/man1.
Make sure to source ``/etc/profile`` in your ``.bashrc``::
Make sure to source ``/etc/profile`` in your ``.bashrc`` or ``.zshrc`` ::
source /etc/profile

11
_j Normal file
View File

@ -0,0 +1,11 @@
#compdef j
cur=${words[2, -1]}
ret=$(autojump --completion "${cur[*]}")
if [ "$ret" != "" ]; then # if at least one answer
for i in $(echo "$ret"); do
compadd -U $i # add all of them as possible completion
done
fi

View File

@ -75,8 +75,9 @@ except IOError:
path_dict={}
if ('-a','') in optlist:
dicadd(path_dict,args[-1])
save(path_dict,dic_file)
if(args[-1] != os.path.expanduser("~")): # home dir can be reached quickly by "cd" and may interfere with other directory
dicadd(path_dict,args[-1])
save(path_dict,dic_file)
elif ('--stat','') in optlist:
a=path_dict.items()
a.sort(key=lambda e:e[1])

View File

@ -1,5 +1,6 @@
#Source autojump.bashrc only if we're on bash, as it is
#not compatible with other shells
# Source autojump on BASH or ZSH depending on the shell
if [ "$BASH_VERSION" ] && [ -n "$PS1" ] && echo $SHELLOPTS | grep -v posix >>/dev/null; then
. /etc/profile.d/autojump.bash
elif [ "$ZSH_VERSION" ] && [ -n "$PS1" ]; then
. /etc/profile.d/autojump.zsh
fi

7
autojump.zsh Executable file
View File

@ -0,0 +1,7 @@
function preexec() {
(autojump -a "$(pwd -P)"&)>/dev/null
}
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";fi }

37
install.zsh Executable file
View File

@ -0,0 +1,37 @@
#! /bin/zsh
# applet icon
sudo mkdir -p /usr/share/autojump/
sudo cp icon.png /usr/share/autojump/
# scripts
sudo cp jumpapplet /usr/bin/
sudo cp autojump /usr/bin/
# man pages
sudo cp autojump.1 /usr/share/man/man1/
# autocompletion file in the first directory of the FPATH variable
cp _j $(echo $FPATH | cut -d":" -f 1)
if [ -d "/etc/profile.d" ]; then
sudo cp autojump.zsh /etc/profile.d/
sudo cp autojump.sh /etc/profile.d/
echo "Remember to add the line"
echo " source /etc/profile"
echo "to your ~/.zshrc if it's not there already"
else
echo "Your distribution does not have a /etc/profile.d directory, the default that we install one of the scripts to. Would you like us to copy it into your ~/.zshrc file to make it work? (If you have done this once before, delete the old version before doing it again.) [y/n]"
read ans
if [ ${#ans} -gt 0 ]; then
if [ $ans = "y" -o $ans = "Y" -o $ans = "yes" -o $ans = "Yes" ]; then
echo "" >> ~/.zshrc
echo "#autojump" >> ~/.zshrc
cat autojump.zsh >> ~/.zshrc
else
echo "Then you need to put autojump.zsh, or the code from it, somewhere where it will get read. Good luck!"
fi
else
echo "Then you need to put autojump.zsh, or the code from it, somewhere where it will get read. Good luck!"
fi
fi