From f39cba1d9f34d7ad0b8d84e80217a39edca6db6d Mon Sep 17 00:00:00 2001 From: exploide Date: Fri, 6 Mar 2020 12:02:39 +0100 Subject: [PATCH] added functions to complete user and group IDs --- share/functions/__fish_complete_group_ids.fish | 7 +++++++ share/functions/__fish_complete_user_ids.fish | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 share/functions/__fish_complete_group_ids.fish create mode 100644 share/functions/__fish_complete_user_ids.fish diff --git a/share/functions/__fish_complete_group_ids.fish b/share/functions/__fish_complete_group_ids.fish new file mode 100644 index 000000000..f6a1e408e --- /dev/null +++ b/share/functions/__fish_complete_group_ids.fish @@ -0,0 +1,7 @@ +function __fish_complete_group_ids --description "Complete group IDs with group name as description" + if command -sq getent + getent group | string replace -f -r '^([[:alpha:]][^:]*):[^:]*:(\d+).*' '$2\t$1' + else if test -r /etc/group + string replace -f -r '^([[:alpha:]][^:]*):[^:]*:(\d+).*' '$2\t$1' < /etc/group + end +end diff --git a/share/functions/__fish_complete_user_ids.fish b/share/functions/__fish_complete_user_ids.fish new file mode 100644 index 000000000..24bf2add6 --- /dev/null +++ b/share/functions/__fish_complete_user_ids.fish @@ -0,0 +1,7 @@ +function __fish_complete_user_ids --description "Complete user IDs with user name as description" + if command -sq getent + getent passwd | string replace -f -r '^([[:alpha:]][^:]*):[^:]*:(\d+).*' '$2\t$1' + else if test -r /etc/passwd + string replace -f -r '^([[:alpha:]][^:]*):[^:]*:(\d+).*' '$2\t$1' < /etc/passwd + end +end