diff --git a/bin/autojump.sh b/bin/autojump.sh index 1d19202..ed58139 100644 --- a/bin/autojump.sh +++ b/bin/autojump.sh @@ -4,14 +4,14 @@ shell=$(echo ${SHELL} | awk -F/ '{ print $NF }') # prevent circular loop for sh shells if [ "${shell}" = "sh" ]; then - return 0 + return 0 # check local install -elif [ -s ~/.autojump/etc/profile.d/autojump.${shell} ]; then - source ~/.autojump/etc/profile.d/autojump.${shell} +elif [ -s ~/.autojump/usr/local/share/autojump/autojump.${shell} ]; then + source ~/.autojump/usr/local/share/autojump/autojump.${shell} # check global install -elif [ -s /etc/profile.d/autojump.${shell} ]; then - source /etc/profile.d/autojump.${shell} +elif [ -s /usr/local/share/autojump/autojump.${shell} ]; then + source /usr/local/share/autojump/autojump.${shell} fi diff --git a/install.py b/install.py index 0e8d95a..0e03d59 100755 --- a/install.py +++ b/install.py @@ -29,23 +29,23 @@ def mkdir(path, dryrun=False): os.makedirs(path) -def modify_autojump_sh(etc_dir, dryrun=False): +def modify_autojump_sh(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) + \nfi\n" % (share_dir, share_dir) - with open(os.path.join(etc_dir, 'autojump.sh'), 'a') as f: + with open(os.path.join(share_dir, 'autojump.sh'), 'a') as f: f.write(custom_install) def modify_autojump_lua(clink_dir, bin_dir, dryrun=False): """Prepend custom AUTOJUMP_BIN_DIR definition to autojump.lua""" custom_install = "local AUTOJUMP_BIN_DIR = \"%s\"\n" % bin_dir.replace( - "\\", - "\\\\") + "\\", + "\\\\") clink_file = os.path.join(clink_dir, 'autojump.lua') with open(clink_file, 'r') as f: original = f.read() @@ -56,12 +56,12 @@ def modify_autojump_lua(clink_dir, bin_dir, dryrun=False): def parse_arguments(): # noqa if platform.system() == 'Windows': default_user_destdir = os.path.join( - os.getenv('LOCALAPPDATA', ''), - 'autojump') + os.getenv('LOCALAPPDATA', ''), + 'autojump') else: default_user_destdir = os.path.join( - os.path.expanduser("~"), - '.autojump') + os.path.expanduser("~"), + '.autojump') default_user_prefix = '' default_user_zshshare = 'functions' default_system_destdir = '/' @@ -70,29 +70,29 @@ def parse_arguments(): # noqa default_clink_dir = os.path.join(os.getenv('LOCALAPPDATA', ''), 'clink') parser = ArgumentParser( - description='Installs autojump globally for root users, otherwise \ + description='Installs autojump globally for root users, otherwise \ installs in current user\'s home directory.') parser.add_argument( - '-n', '--dryrun', action="store_true", default=False, - help='simulate installation') + '-n', '--dryrun', action="store_true", default=False, + help='simulate installation') parser.add_argument( - '-f', '--force', action="store_true", default=False, - help='skip root user, shell type, Python version checks') + '-f', '--force', action="store_true", default=False, + help='skip root user, shell type, Python version checks') parser.add_argument( - '-d', '--destdir', metavar='DIR', default=default_user_destdir, - help='set destination to DIR') + '-d', '--destdir', metavar='DIR', default=default_user_destdir, + help='set destination to DIR') parser.add_argument( - '-p', '--prefix', metavar='DIR', default=default_user_prefix, - help='set prefix to DIR') + '-p', '--prefix', metavar='DIR', default=default_user_prefix, + help='set prefix to DIR') parser.add_argument( - '-z', '--zshshare', metavar='DIR', default=default_user_zshshare, - help='set zsh share destination to DIR') + '-z', '--zshshare', metavar='DIR', default=default_user_zshshare, + help='set zsh share destination to DIR') parser.add_argument( - '-c', '--clinkdir', metavar='DIR', default=default_clink_dir, - help='set clink directory location to DIR (Windows only)') + '-c', '--clinkdir', metavar='DIR', default=default_clink_dir, + help='set clink directory location to DIR (Windows only)') parser.add_argument( - '-s', '--system', action="store_true", default=False, - help='install system wide for all users') + '-s', '--system', action="store_true", default=False, + help='install system wide for all users') args = parser.parse_args() @@ -136,16 +136,16 @@ def parse_arguments(): # noqa return args -def print_post_installation_message(etc_dir, bin_dir): +def print_post_installation_message(share_dir, bin_dir): if platform.system() == 'Windows': print("\nPlease manually add %s to your user path" % bin_dir) else: if get_shell() == 'fish': - aj_shell = '%s/autojump.fish' % etc_dir + aj_shell = '%s/autojump.fish' % share_dir source_msg = "if test -f %s; . %s; end" % (aj_shell, aj_shell) rcfile = '~/.config/fish/config.fish' else: - aj_shell = '%s/autojump.sh' % etc_dir + aj_shell = '%s/autojump.sh' % share_dir source_msg = "[[ -s %s ]] && source %s" % (aj_shell, aj_shell) if platform.system() == 'Darwin' and get_shell() == 'bash': @@ -167,20 +167,19 @@ def main(args): print("Installing autojump to %s ..." % args.destdir) bin_dir = os.path.join(args.destdir, args.prefix, 'bin') - etc_dir = os.path.join(args.destdir, 'etc', 'profile.d') doc_dir = os.path.join(args.destdir, args.prefix, 'share', 'man', 'man1') - icon_dir = os.path.join(args.destdir, args.prefix, 'share', 'autojump') + share_dir = os.path.join(args.destdir, args.prefix, 'share', 'autojump') zshshare_dir = os.path.join(args.destdir, args.zshshare) mkdir(bin_dir, args.dryrun) mkdir(doc_dir, args.dryrun) - mkdir(icon_dir, args.dryrun) + mkdir(share_dir, args.dryrun) cp('./bin/autojump', bin_dir, args.dryrun) cp('./bin/autojump_argparse.py', bin_dir, args.dryrun) cp('./bin/autojump_data.py', bin_dir, args.dryrun) cp('./bin/autojump_utils.py', bin_dir, args.dryrun) - cp('./bin/icon.png', icon_dir, args.dryrun) + cp('./bin/icon.png', share_dir, args.dryrun) cp('./docs/autojump.1', doc_dir, args.dryrun) if platform.system() == 'Windows': @@ -194,20 +193,19 @@ def main(args): if args.custom_install: modify_autojump_lua(args.clinkdir, bin_dir, args.dryrun) else: - mkdir(etc_dir, args.dryrun) + mkdir(share_dir, args.dryrun) mkdir(zshshare_dir, args.dryrun) - cp('./bin/autojump.sh', etc_dir, args.dryrun) - cp('./bin/autojump.bash', etc_dir, args.dryrun) - cp('./bin/autojump.fish', etc_dir, args.dryrun) - cp('./bin/autojump.zsh', etc_dir, args.dryrun) + cp('./bin/autojump.sh', share_dir, args.dryrun) + cp('./bin/autojump.bash', share_dir, args.dryrun) + cp('./bin/autojump.fish', share_dir, args.dryrun) + cp('./bin/autojump.zsh', share_dir, args.dryrun) cp('./bin/_j', zshshare_dir, args.dryrun) if args.custom_install: - modify_autojump_sh(etc_dir, args.dryrun) + modify_autojump_sh(share_dir, args.dryrun) - - print_post_installation_message(etc_dir, bin_dir) + print_post_installation_message(share_dir, bin_dir) if __name__ == "__main__":