added functions to complete user and group IDs

This commit is contained in:
exploide 2020-03-06 12:02:39 +01:00 committed by Johannes Altmanninger
parent 660182cfb3
commit f39cba1d9f
2 changed files with 14 additions and 0 deletions

View File

@ -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

View File

@ -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