From b54f09194182d2a8b14349301c832adbe60c6260 Mon Sep 17 00:00:00 2001 From: Daniel de Cloet Date: Tue, 31 May 2022 13:35:54 +0200 Subject: [PATCH 1/2] Add dependencies for tab completion docker-env --- templates/zshrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/zshrc b/templates/zshrc index 48ce6f8..a71e1ab 100644 --- a/templates/zshrc +++ b/templates/zshrc @@ -240,8 +240,8 @@ function _docker-env() { "-h[Container host name]" \ "-m[Memory limit]" \ "-u[Username or UID (format: (|(:)))]" \ - "(-p -e -v -w)--[Explicitely stop switches and start positional arguments]" \ - "(-p -e -v -w --)1:Container image:->image" \ + "(-p -e -v -w -h -m -u)--[Explicitely stop switches and start positional arguments]" \ + "(-p -e -v -w -h -m -u --)1:Container image:->image" \ "*:Container CMD:->cmd" case $state in From 373c2edd8497d89370c9730e2789741e416faed7 Mon Sep 17 00:00:00 2001 From: Daniel de Cloet Date: Tue, 31 May 2022 13:36:10 +0200 Subject: [PATCH 2/2] Fix dynamic run_command_switches appending --- templates/zshrc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/templates/zshrc b/templates/zshrc index a71e1ab..9323d23 100644 --- a/templates/zshrc +++ b/templates/zshrc @@ -218,11 +218,14 @@ EOS index=$(docker ps -a --filter "name=docker-env-$image_repository-*" --format '{% raw %}{{.Names}}{% endraw %}' | perl -e 'my $max = 0; while (<>) {my ($n) = $_ =~ /(\d+)$/; if ($n > $max) { $max = $n };}; print $max+1;') name="docker-env-$image_repository-$index" - run_command="docker run --rm -it --name \"$name\" -v $(pwd):/work_dir " + run_command="docker run --rm -it --name \"$name\" -v \"$(pwd):/work_dir\" " - run_command+="${run_command_switches[*]}" + for run_command_switch in $run_command_switches + do + run_command+="\"$run_command_switch\" " + done - run_command+=" -w \"$workdir\" \"$image\" $cmd" + run_command+="-w \"$workdir\" \"$image\" $cmd" eval $run_command }