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

@ -22,4 +22,9 @@ To run command line help:
```
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/',
description='Ssh connection manager',
license='DWTWL 2.5',
version='0.7',
version='0.8',
py_modules=['sshch'],
scripts=['sshch/sshch'],

View File

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