From 5b5f68f1dd4395f0ef7231218295d1c633d4288b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 22 Dec 2021 13:26:35 +0100 Subject: Make bash completion work when nix is invoked as ~/.../nix --- misc/bash/completion.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'misc/bash/completion.sh') diff --git a/misc/bash/completion.sh b/misc/bash/completion.sh index bea2a40bc..0af90d8c1 100644 --- a/misc/bash/completion.sh +++ b/misc/bash/completion.sh @@ -13,7 +13,7 @@ function _complete_nix { else COMPREPLY+=("$completion") fi - done < <(NIX_GET_COMPLETIONS=$cword "${words[@]}") + done < <(NIX_GET_COMPLETIONS=$cword "${words[@]/#\~/$HOME}") __ltrim_colon_completions "$cur" } -- cgit v1.2.3 From 1da1b2b345ccf32220a2628622ee8b170d9d521a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Na=C3=AFm=20Favier?= Date: Wed, 22 Dec 2021 12:37:59 +0100 Subject: Don't insert spaces when completing attribute paths --- misc/bash/completion.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'misc/bash/completion.sh') diff --git a/misc/bash/completion.sh b/misc/bash/completion.sh index bea2a40bc..3eb44dfa6 100644 --- a/misc/bash/completion.sh +++ b/misc/bash/completion.sh @@ -7,8 +7,10 @@ function _complete_nix { local completion=${line%% *} if [[ -z $have_type ]]; then have_type=1 - if [[ $completion = filenames ]]; then + if [[ $completion == filenames ]]; then compopt -o filenames + elif [[ $completion == attrs ]]; then + compopt -o nospace fi else COMPREPLY+=("$completion") -- cgit v1.2.3 From 9d840758a8d195e52e8b7d08cd9c15f6b8259724 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Fri, 4 Feb 2022 22:43:16 +0100 Subject: completions: pipe stderr to /dev/null This fixes weird issues where e.g. nix build -L .# deletes the current line from the prompt. --- misc/bash/completion.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'misc/bash/completion.sh') diff --git a/misc/bash/completion.sh b/misc/bash/completion.sh index 8fc224792..045053dee 100644 --- a/misc/bash/completion.sh +++ b/misc/bash/completion.sh @@ -15,7 +15,7 @@ function _complete_nix { else COMPREPLY+=("$completion") fi - done < <(NIX_GET_COMPLETIONS=$cword "${words[@]/#\~/$HOME}") + done < <(NIX_GET_COMPLETIONS=$cword "${words[@]/#\~/$HOME}" 2>/dev/null) __ltrim_colon_completions "$cur" } -- cgit v1.2.3