mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
modify autojump.sh for custom installs
This commit is contained in:
parent
661f17791c
commit
c7c8bceac9
@ -14,8 +14,4 @@ elif [ -s ~/.autojump/etc/profile.d/autojump.${shell} ]; then
|
|||||||
elif [ -s /etc/profile.d/autojump.${shell} ]; then
|
elif [ -s /etc/profile.d/autojump.${shell} ]; then
|
||||||
source /etc/profile.d/autojump.${shell}
|
source /etc/profile.d/autojump.${shell}
|
||||||
|
|
||||||
# check custom install locations (modified by Homebrew or using --destdir option)
|
|
||||||
#custom# elif [ -s destdir_install/autojump.${shell} ]; then
|
|
||||||
#custom# source destdir_install/autojump.${shell}
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
37
install.py
37
install.py
@ -28,6 +28,18 @@ def mkdir(path, dryrun=False):
|
|||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
|
|
||||||
|
|
||||||
|
def modify_autojump_sh(etc_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)
|
||||||
|
|
||||||
|
|
||||||
def parse_arguments():
|
def parse_arguments():
|
||||||
default_user_destdir = os.path.join(os.path.expanduser("~"), '.autojump')
|
default_user_destdir = os.path.join(os.path.expanduser("~"), '.autojump')
|
||||||
default_user_prefix = ''
|
default_user_prefix = ''
|
||||||
@ -65,17 +77,27 @@ def parse_arguments():
|
|||||||
print("Unsupported shell: %s" % os.getenv('SHELL'), file=sys.stderr)
|
print("Unsupported shell: %s" % os.getenv('SHELL'), file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
if args.destdir != default_user_destdir \
|
||||||
|
or args.prefix != default_user_prefix \
|
||||||
|
or args.zshshare != default_user_zshshare:
|
||||||
|
args.custom_install = True
|
||||||
|
else:
|
||||||
|
args.custom_install = False
|
||||||
|
|
||||||
if args.system:
|
if args.system:
|
||||||
if os.geteuid() != 0:
|
if os.geteuid() != 0:
|
||||||
print("Please rerun as root for system-wide installation.",
|
print("Please rerun as root for system-wide installation.",
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if args.destdir == default_user_destdir:
|
|
||||||
args.destdir = default_system_destdir
|
if args.custom_install:
|
||||||
if args.prefix == default_user_prefix:
|
print("Custom paths incompatible with --system option.",
|
||||||
args.prefix = default_system_prefix
|
file=sys.stderr)
|
||||||
if args.zshshare == default_user_zshshare:
|
sys.exit(1)
|
||||||
args.zshshare = default_system_zshshare
|
|
||||||
|
args.destdir = default_system_destdir
|
||||||
|
args.prefix = default_system_prefix
|
||||||
|
args.zshshare = default_system_zshshare
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
@ -117,7 +139,8 @@ def main(args):
|
|||||||
cp('./bin/icon.png', icon_dir, args.dryrun)
|
cp('./bin/icon.png', icon_dir, args.dryrun)
|
||||||
cp('./docs/autojump.1', doc_dir, args.dryrun)
|
cp('./docs/autojump.1', doc_dir, args.dryrun)
|
||||||
|
|
||||||
# TODO(ting|2013-12-30): modify autojump.sh for custom installs
|
if args.custom_install:
|
||||||
|
modify_autojump_sh(etc_dir, args.dryrun)
|
||||||
|
|
||||||
print_post_installation_message(etc_dir)
|
print_post_installation_message(etc_dir)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user