From c057e1e8edd40706aad78de460fcf9c71846dfa7 Mon Sep 17 00:00:00 2001 From: zlaxy Date: Wed, 13 Sep 2017 12:03:00 +0300 Subject: [PATCH] Adding autocompetion instructions to README and fixing lack of 'exec_string' parameter crashing --- README.md | 7 ++++++- setup.py | 2 +- sshch/sshch | 24 +++++++++++++++--------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 2fe793c..97f0dcd 100644 --- a/README.md +++ b/README.md @@ -22,4 +22,9 @@ To run command line help: ``` sshch -h ``` -**If you want to use unsafe 'password' feature you must install 'sshpass' first.** \ No newline at end of file +**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) \ No newline at end of file diff --git a/setup.py b/setup.py index ac65b24..073dc9d 100644 --- a/setup.py +++ b/setup.py @@ -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'], diff --git a/sshch/sshch b/sshch/sshch index 149873b..1800915 100755 --- a/sshch/sshch +++ b/sshch/sshch @@ -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)