Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions bash-pinyin-completion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,19 @@ int main(int argc, char **argv) {
input = home + input;
}
auto split = split_string(input, '/');
auto final = split.back();
if (input.back() != '/') {
string final;
if (input.back() == '/') {
final = "";
} else {
final = split.back();
split.pop_back();
}
auto pinyin = string_pinyin(final);
auto compgen_opts = string(argv[2]);
// Navigate to the dir we need to complete
auto dest = filesystem::path(input.c_str()).parent_path();
if (!dest.empty()) {
if (!filesystem::exists(dest)) {
if (!filesystem::exists(dest) || !filesystem::is_directory(dest)) {
return 0;
}
filesystem::current_path(dest);
Expand All @@ -139,6 +142,7 @@ int main(int argc, char **argv) {
auto compreply = split_string(run_command("/usr/bin/env bash -c \"compgen " + compgen_opts + "\""), '\n');
for (auto reply : compreply) {
auto reply_pinyin = string_pinyin(reply);
if (reply_pinyin == reply) continue;
if (reply_pinyin.compare(0, pinyin.size(), pinyin) == 0) {
for (auto substr : split) {
cout << substr << "/";
Expand Down
10 changes: 8 additions & 2 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
bash-pinyin-completion (0.0.3) unstable; urgency=medium

* fix sshfs command tab shows multiple home.

-- lichenggang <lichenggang@deepin.org> Wed, 09 Jul 2025 10:44:25 +0800

bash-pinyin-completion (0.0.2) unstable; urgency=medium

* Fix completion exception.
* Move logic to C++, fix several issues

-- lichenggang <lichenggang@deepin.org> Thu, 03 Jul 2025 14:31:32 +0800
-- April Lu <apr3vau@outlook.com> Wed, 09 Jul 2025 10:10:00 +0800

bash-pinyin-completion (0.0.1) unstable; urgency=medium

Expand Down
4 changes: 2 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Source: bash-pinyin-completion
Section: shells
Priority: optional
Maintainer: Deepin Packages Builder <packages@linuxdeepin.com>
Maintainer: April Lu <apr3vau@outlook.com>
Build-Depends: debhelper-compat (= 13)
Standards-Version: 4.7.2.0
Homepage: https://github.com/apr3vau/bash-pinyin-completion-cpp
Homepage: https://github.com/calsym456/bash-pinyin-completion-cpp

Package: bash-pinyin-completion
Architecture: any
Expand Down
9 changes: 8 additions & 1 deletion scripts/bash_pinyin_completion
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ _pinyin_completion() {

# Main part
local -a pinyin_matched
readarray -t pinyin_matched < <(bash-pinyin-completion "$cur" "$compgen_opts")
if [[ "${compgen_opts[0]}" == -d ]]; then
readarray -t pinyin_matched < <(bash-pinyin-completion "$cur" "-d")
else
readarray -t pinyin_matched < <(bash-pinyin-completion "$cur" "-f")
if [ ${#pinyin_matched[@]} -ne 0 ]; then
compopt -o filenames 2>/dev/null
fi
fi

# merge result
local -a old_candidates=("${COMPREPLY[@]}")
Expand Down
38 changes: 0 additions & 38 deletions test.sh

This file was deleted.

Loading