From cea75c27fe7125110e1b9749f07773fed3055e7e Mon Sep 17 00:00:00 2001 From: Ashwin Vishnu Date: Fri, 31 May 2019 09:41:37 +0200 Subject: [PATCH 1/2] Do not write files when in dry run --- install.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/install.py b/install.py index a44fecc..5cdfb64 100755 --- a/install.py +++ b/install.py @@ -37,8 +37,9 @@ def modify_autojump_sh(etc_dir, share_dir, dryrun=False): \n source %s/autojump.${shell} \ \nfi\n' % (share_dir, share_dir) - with open(os.path.join(etc_dir, 'autojump.sh'), 'a') as f: - f.write(custom_install) + if not dryrun: + with open(os.path.join(etc_dir, 'autojump.sh'), 'a') as f: + f.write(custom_install) def modify_autojump_lua(clink_dir, bin_dir, dryrun=False): @@ -48,10 +49,11 @@ def modify_autojump_lua(clink_dir, bin_dir, dryrun=False): '\\\\', ) clink_file = os.path.join(clink_dir, 'autojump.lua') - with open(clink_file, 'r') as f: - original = f.read() - with open(clink_file, 'w') as f: - f.write(custom_install + original) + if not dryrun: + with open(clink_file, 'r') as f: + original = f.read() + with open(clink_file, 'w') as f: + f.write(custom_install + original) def parse_arguments(): # noqa From 73694897c36b48b7c03a7053237807d390b503df Mon Sep 17 00:00:00 2001 From: Ashwin Vishnu Date: Sat, 27 Jul 2019 12:17:12 +0200 Subject: [PATCH 2/2] Open EDITOR if output of autojump is a file --- bin/autojump.bash | 2 ++ bin/autojump.zsh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/bin/autojump.bash b/bin/autojump.bash index 379e529..abf927e 100644 --- a/bin/autojump.bash +++ b/bin/autojump.bash @@ -67,6 +67,8 @@ j() { echo -e "${output}" fi cd "${output}" + elif [[ -f "${output}" ]]; then + $EDITOR "${output}" else echo "autojump: directory '${@}' not found" echo "\n${output}\n" diff --git a/bin/autojump.zsh b/bin/autojump.zsh index a761206..beaf8e7 100644 --- a/bin/autojump.zsh +++ b/bin/autojump.zsh @@ -61,6 +61,8 @@ j() { echo -e "${output}" fi cd "${output}" + elif [[ -f "${output}" ]]; then + $EDITOR "${output}" else echo "autojump: directory '${@}' not found" echo "\n${output}\n"