fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Johannes AltmanningerMark private functions that don't need localizationa53db7256

master
1.1 KiB20 linesraw
1# localization: skip(private)
2#
3# This should be used where you want user names with a description. Such as in an argument
4# completion. If you just want a list of user names use __fish_print_users.
5# The string replace command takes into account GECOS-formatted description fields, by retaining
6# only the first field, the relevant one, from the comma-separated list
7function __fish_complete_users --description "Print a list of local users, with the real user name as a description"
8    if command -sq getent
9        command getent passwd | while read -l line
10            string split -f 1,5 : -- $line | string join \t | string replace -r ',.*' ''
11        end
12    else if command -sq dscl
13        # This is the "Directory Service command line utility" used on macOS in place of getent.
14        command dscl . -list /Users RealName | string match -r -v '^_' | string replace -r ' {2,}' \t
15    else if test -r /etc/passwd
16        string match -v -r '^\s*#' </etc/passwd | while read -l line
17            string split -f 1,5 : -- $line | string join \t | string replace -r ',.*' ''
18        end
19    end
20end