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

Update the shell snippets to use the XDG spec.

This commit is contained in:
Tanguy Ortolo 2011-07-24 21:08:56 +02:00
parent 88575c72f8
commit a45d94167f
2 changed files with 14 additions and 13 deletions

View File

@ -25,23 +25,24 @@ _autojump()
done < <(autojump --bash --completion $cur)
}
complete -F _autojump j
#data_dir=${XDG_DATA_HOME:-$([ -e ~/.local/share ] && echo ~/.local/share || echo ~)}
data_dir=$([ -e ~/.local/share ] && echo ~/.local/share || echo ~)
export AUTOJUMP_HOME=${HOME}
if [[ "$data_dir" = "${HOME}" ]]
#determine the data directory according to the XDG Base Directory Specification
if [ -n "$XDG_DATA_HOME" ]
then
export AUTOJUMP_DATA_DIR=${data_dir}
export AUTOJUMP_DATA_DIR="$XDG_DATA_HOME/autojump"
else
export AUTOJUMP_DATA_DIR=${data_dir}/autojump
export AUTOJUMP_DATA_DIR=~/.local/share/autojump
fi
if [ ! -e "${AUTOJUMP_DATA_DIR}" ]
then
mkdir "${AUTOJUMP_DATA_DIR}"
mkdir -p "${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
export AUTOJUMP_HOME=${HOME}
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="${PROMPT_COMMAND:-:} ; $AUTOJUMP"

View File

@ -14,17 +14,17 @@
#You should have received a copy of the GNU General Public License
#along with autojump. If not, see <http://www.gnu.org/licenses/>.
#local data_dir=${XDG_DATA_HOME:-$([ -e ~/.local/share ] && echo ~/.local/share || echo ~)}
local data_dir=$([ -e ~/.local/share ] && echo ~/.local/share || echo ~)
if [[ "$data_dir" = "${HOME}" ]]
#determine the data directory according to the XDG Base Directory Specification
if [ -n "$XDG_DATA_HOME" ]
then
export AUTOJUMP_DATA_DIR=${data_dir}
export AUTOJUMP_DATA_DIR="$XDG_DATA_HOME/autojump"
else
export AUTOJUMP_DATA_DIR=${data_dir}/autojump
export AUTOJUMP_DATA_DIR=~/.local/share/autojump
fi
if [ ! -e "${AUTOJUMP_DATA_DIR}" ]
then
mkdir "${AUTOJUMP_DATA_DIR}"
mkdir -p "${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