Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not write files when in dry run #579

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bin/autojump.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions bin/autojump.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 8 additions & 6 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down