summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorKoichi Murase <myoga.murase@gmail.com>2025-06-04 12:30:31 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2025-06-09 21:46:53 +0900
commitf6c589c606a8936e33778a717d6200632f8cab21 (patch)
tree55100398637854f47f55dd3d94f2a075d33caf91 /shell
parent2bd29c3172bb87e447450b8b2034b4dd868fd97c (diff)
downloadfzf-f6c589c606a8936e33778a717d6200632f8cab21.tar.gz
[bash,zsh] Skip comments in ~/.ssh/config
For the line "Host host1 # this is a comment", the current implementation generates words in an inline comment as hostnames. This patch removes the comment before generating the hostname.
Diffstat (limited to 'shell')
-rw-r--r--shell/completion.bash1
-rw-r--r--shell/completion.zsh1
2 files changed, 2 insertions, 0 deletions
diff --git a/shell/completion.bash b/shell/completion.bash
index 044a35f6..c3121ecc 100644
--- a/shell/completion.bash
+++ b/shell/completion.bash
@@ -499,6 +499,7 @@ if ! declare -F __fzf_list_hosts > /dev/null; then
# 16-year-old mawk unfortunately. We need to use [ \t] instead.
match(tolower($0), /^[ \t]*host(name)?[ \t]*[ \t=]/) {
$0 = substr($0, RLENGTH + 1) # Remove "Host(name)?=?"
+ sub(/#.*/, "")
for (i = 1; i <= NF; i++)
if ($i !~ /[*?%]/)
print $i
diff --git a/shell/completion.zsh b/shell/completion.zsh
index 0f20812a..b9f9baa0 100644
--- a/shell/completion.zsh
+++ b/shell/completion.zsh
@@ -277,6 +277,7 @@ if ! declare -f __fzf_list_hosts > /dev/null; then
# 16-year-old mawk unfortunately. We need to use [ \t] instead.
match(tolower($0), /^[ \t]*host(name)?[ \t]*[ \t=]/) {
$0 = substr($0, RLENGTH + 1) # Remove "Host(name)?=?"
+ sub(/#.*/, "")
for (i = 1; i <= NF; i++)
if ($i !~ /[*?%]/)
print $i