Adding autocompetion instructions to README and fixing lack of 'exec_string' parameter crashing

This commit is contained in:
ivan 2017-09-13 12:03:00 +03:00
parent 0266d29308
commit c057e1e8ed
3 changed files with 22 additions and 11 deletions

View File

@ -23,3 +23,8 @@ To run command line help:
sshch -h sshch -h
``` ```
**If you want to use unsafe 'password' feature you must install 'sshpass' first.** **If you want to use unsafe 'password' feature you must install 'sshpass' first.**
If you want to use bash autocompletion function with sshch, copy autocompletion script to /etc/bash_completion.d/:
```
sudo cp sshch_bash_completion.sh /etc/bash_completion.d/sshch
```
(changes will come into effect with new bash session)

View File

@ -10,7 +10,7 @@ def main():
url='https://github.com/zlaxy/sshch/', url='https://github.com/zlaxy/sshch/',
description='Ssh connection manager', description='Ssh connection manager',
license='DWTWL 2.5', license='DWTWL 2.5',
version='0.7', version='0.8',
py_modules=['sshch'], py_modules=['sshch'],
scripts=['sshch/sshch'], scripts=['sshch/sshch'],

View File

@ -16,7 +16,7 @@ import time
# https://github.com/zlaxy/sshch # https://github.com/zlaxy/sshch
version = "0.7" version = "0.8"
# path to conf file, default: ~/.config/sshch.conf # path to conf file, default: ~/.config/sshch.conf
conf_file = path.expanduser("~") + '/.config/sshch.conf' conf_file = path.expanduser("~") + '/.config/sshch.conf'
@ -54,6 +54,7 @@ def ConnectAlias(alias, command=False):
password = base64.b32decode(base64.b16decode( password = base64.b32decode(base64.b16decode(
base64.b64decode(conf.get(alias, "password")))) base64.b64decode(conf.get(alias, "password"))))
exec_string = 'sshpass -p "' + password + '" ' exec_string = 'sshpass -p "' + password + '" '
if conf.has_option(alias, "exec_string"):
exec_string = exec_string + conf.get(alias, "exec_string") exec_string = exec_string + conf.get(alias, "exec_string")
if command: if command:
exec_string = exec_string + " " + command exec_string = exec_string + " " + command
@ -133,8 +134,9 @@ def CMDList(option, opt, value, parser):
def CMDFullList(option, opt, value, parser): def CMDFullList(option, opt, value, parser):
for p in conf.sections(): for p in conf.sections():
to_print = "".join([str(p), " - ", conf.get(p, "exec_string"), to_print = "".join([str(p), " - ", (conf.get(p, "exec_string") if
(" [password]" if conf.has_option(p, "password") else ""), "\n"]) conf.has_option(p, "exec_string") else ""),
(" [password]" if conf.has_option(p, "password") else "")])
print(to_print) print(to_print)
@ -332,8 +334,9 @@ def CursesMain():
else: else:
password = "" password = ""
exec_string = ["[", selected_strings[i], "] ", str(i), " ", exec_string = ["[", selected_strings[i], "] ", str(i), " ",
strings[i - 1], " (", conf.get(strings[i - 1], "exec_string"), strings[i - 1], " (", (conf.get(strings[i - 1],
")", password] "exec_string") if conf.has_option(strings[i - 1],
"exec_string") else ""), ")", password]
if (i == position): if (i == position):
box.addnstr(i, 2, "".join(exec_string), width - 6, highlight_text) box.addnstr(i, 2, "".join(exec_string), width - 6, highlight_text)
else: else:
@ -386,7 +389,9 @@ def CursesMain():
while edit_string.rstrip() == "": while edit_string.rstrip() == "":
string_textpad = CursesTextpad(screen, 3, width - 8, string_textpad = CursesTextpad(screen, 3, width - 8,
(height // 2) - 1, 4, "Enter new execution string:", (height // 2) - 1, 4, "Enter new execution string:",
conf.get(strings[position - 1], "exec_string"), (conf.get(strings[position - 1],
"exec_string") if conf.has_option(strings[position - 1],
"exec_string") else ""),
normal_text, highlight_text) normal_text, highlight_text)
edit_string = string_textpad.edit(CursesTextpadConfirm) edit_string = string_textpad.edit(CursesTextpadConfirm)
SetAliasString(strings[position - 1], SetAliasString(strings[position - 1],
@ -533,8 +538,9 @@ def CursesMain():
else: else:
password = "" password = ""
exec_string = ["[", selected_strings[i], "] ", str(i), " ", exec_string = ["[", selected_strings[i], "] ", str(i), " ",
strings[i - 1], " (", conf.get(strings[i - 1], "exec_string"), strings[i - 1], " (", (conf.get(strings[i - 1],
")", password] "exec_string") if conf.has_option(strings[i - 1],
"exec_string") else ""), ")", password]
if (i + (max_row * (page - 1)) == (position + (max_row * (page - 1)))): if (i + (max_row * (page - 1)) == (position + (max_row * (page - 1)))):
box.addnstr(i - (max_row * (page - 1)), 2, "".join( box.addnstr(i - (max_row * (page - 1)), 2, "".join(
exec_string), width - 6, highlight_text) exec_string), width - 6, highlight_text)