mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
Write custom share_dirs into autojump.sh
This commit is contained in:
parent
f75d01299d
commit
8228ba41c8
@ -21,7 +21,10 @@ elif [ -s ~/.autojump/share/autojump/autojump.${shell} ]; then
|
||||
source ~/.autojump/share/autojump/autojump.${shell}
|
||||
|
||||
# check global install
|
||||
elif [ -s /usr/local/share/autojump/autojump.${shell} ]; then
|
||||
source /usr/local/share/autojump/autojump.${shell}
|
||||
elif [ -s ${share_dir}/autojump.${shell} ]; then
|
||||
source ${share_dir}/autojump.${shell}
|
||||
|
||||
# check custom install
|
||||
elif [ -s ${etc_dir}/autojump.${shell} ]; then
|
||||
source ${etc_dir}/autojump.${shell}
|
||||
fi
|
||||
|
19
install.py
19
install.py
@ -9,6 +9,7 @@ import sys
|
||||
|
||||
sys.path.append('bin')
|
||||
from autojump_argparse import ArgumentParser
|
||||
from string import Template
|
||||
|
||||
SUPPORTED_SHELLS = ('bash', 'zsh', 'fish', 'tcsh')
|
||||
|
||||
@ -29,16 +30,16 @@ def mkdir(path, dryrun=False):
|
||||
os.makedirs(path)
|
||||
|
||||
|
||||
def modify_autojump_sh(etc_dir, dryrun=False):
|
||||
def modify_autojump_sh(etc_dir, share_dir, dryrun=False):
|
||||
"""Append custom installation path to autojump.sh"""
|
||||
custom_install = "\
|
||||
\n# check custom install \
|
||||
\nif [ -s %s/autojump.${shell} ]; then \
|
||||
\n\tsource %s/autojump.${shell} \
|
||||
\nfi\n" % (etc_dir, etc_dir)
|
||||
|
||||
with open(os.path.join(etc_dir, 'autojump.sh'), 'a') as f:
|
||||
f.write(custom_install)
|
||||
autojumpsh = os.path.join(etc_dir, 'autojump.sh')
|
||||
with open(autojumpsh, 'r') as f:
|
||||
content = f.read()
|
||||
tmpl = Template(content)
|
||||
new_content = tmpl.safe_substitute(etc_dir=etc_dir, share_dir=share_dir)
|
||||
with open(autojumpsh, 'w') as f:
|
||||
f.write(new_content)
|
||||
|
||||
|
||||
def modify_autojump_lua(clink_dir, bin_dir, dryrun=False):
|
||||
@ -207,7 +208,7 @@ def main(args):
|
||||
cp('./bin/_j', zshshare_dir, args.dryrun)
|
||||
|
||||
if args.custom_install:
|
||||
modify_autojump_sh(etc_dir, args.dryrun)
|
||||
modify_autojump_sh(etc_dir, share_dir, args.dryrun)
|
||||
|
||||
show_post_installation_message(etc_dir, share_dir, bin_dir)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user