From 6bdb255bfac9ecab9fd56f864b663c151d789e73 Mon Sep 17 00:00:00 2001 From: Artem Bliznetsov Date: Thu, 18 Apr 2024 22:38:34 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=B0=D0=B2=D1=82=D0=BE=D0=B7=D0=B0=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F,=20=D0=B8=D1=81=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?pv=20=D0=B4=D0=BB=D1=8F=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B3=D1=80?= =?UTF-8?q?=D0=B5=D1=81=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- completion | 2 +- helperlib.py | 5 +++-- scp-completion.py | 14 ++++++-------- scp-helper | 7 ++++++- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/completion b/completion index f6824f6..2d3b92b 100644 --- a/completion +++ b/completion @@ -14,4 +14,4 @@ function _scp_path_completition() } complete -F _ssh_connector_completion ssh-helper -complete -F _scp_path_completition scp-helper +complete -o nospace -F _scp_path_completition scp-helper diff --git a/helperlib.py b/helperlib.py index 69043b0..b4ee4ae 100644 --- a/helperlib.py +++ b/helperlib.py @@ -1,7 +1,5 @@ import os -CMD_TAR_DECOMP='tar -xz' -CMD_TAR_COMP='tar -cz' SUDO_REMOTE=True def get_config(): @@ -30,6 +28,9 @@ def parse_arg(s): connection_name = 'local' path = s + if path == '': + path = '/' + if path[0] not in ('/', '~', '.'): if connection_name == 'local': path = './' + path diff --git a/scp-completion.py b/scp-completion.py index 4787128..066f8ef 100755 --- a/scp-completion.py +++ b/scp-completion.py @@ -6,7 +6,7 @@ import sys import subprocess from helperlib import get_config, parse_arg, add_sudo, make_ssh_cmd, get_path_config -DEBUG = True +DEBUG = False SUDO_REMOTE = True def get_conf_names(): @@ -56,8 +56,9 @@ if __name__ == '__main__': cur_arg = get_current_arg(args) if DEBUG: print(f'{cur_arg}', file=sys.stderr) - - if cur_arg is not None and ':' in cur_arg: + + comp_list = [] + if cur_arg is not None: # В нем уже прописали имя подключения cur_set = get_path_config(cur_arg) @@ -69,7 +70,6 @@ if __name__ == '__main__': print(f'{obj_list}', file=sys.stderr) print(cur_set, file=sys.stderr) - comp_list = [] for i in obj_list.split('\n'): i_res = '' if cur_set['connection_name'] != 'local': @@ -86,11 +86,9 @@ if __name__ == '__main__': if DEBUG: print(f'{comp_list}', file=sys.stderr) - print(' '.join(comp_list)) - else: - # Заполняем имя подключения - print('/ '.join(get_conf_names())) + comp_list.extend([f'{i}/' for i in get_conf_names()]) + print(' '.join(comp_list)) diff --git a/scp-helper b/scp-helper index 4a74d84..203a15c 100755 --- a/scp-helper +++ b/scp-helper @@ -7,6 +7,8 @@ import os from helperlib import * +PV_ENABLED = True + if __name__ == '__main__': parser = argparse.ArgumentParser( description='Copy files' @@ -29,7 +31,10 @@ if __name__ == '__main__': make_unpack_cmd ) - full_cmd = f'{in_cmd} | {out_cmd}' + if PV_ENABLED: + full_cmd = f'{in_cmd} | pv | {out_cmd}' + else: + full_cmd = f'{in_cmd} | {out_cmd}' print("Будет выполнена команда:") print(full_cmd) print("продолжить (y/n)")