File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,35 @@ get_download_url() {
49
49
cut -d' "' -f4
50
50
}
51
51
52
+ # get the user's shell (as portably as possible)
53
+ # and print out the command to enable tab completion
54
+ emit_completion_command () {
55
+ local shell file
56
+
57
+ if command -v getent > /dev/null; then
58
+ shell=$( getent passwd " ${USER} " | cut -d: -f7)
59
+ elif command -v finger > /dev/null; then
60
+ shell=$( finger " ${USER} " | sed -nE ' /.*Shell: / { s///; s/ .*//; p; }' )
61
+ elif [[ -f /etc/passwd ]]; then
62
+ shell=$( awk -F: -v u=" ${USER} " ' $1 == u {print $7}' /etc/passwd)
63
+ fi
64
+
65
+ if [[ -z " ${shell} " ]]; then
66
+ # could not detect the shell
67
+ return
68
+ fi
69
+
70
+ file=" bin/completions/configlet.$( basename " ${shell} " ) "
71
+ if [[ -f " ${file} " && -r " ${file} " ]]; then
72
+ case " ${shell} " in
73
+ bash | fish) echo " Enable tab completions: source ${file} " ;;
74
+ zsh)
75
+ : # is there more to do here than the above?
76
+ ;;
77
+ esac
78
+ fi
79
+ }
80
+
52
81
main () {
53
82
if [[ -d ./bin ]]; then
54
83
output_dir=" ./bin"
@@ -69,6 +98,8 @@ main() {
69
98
esac
70
99
71
100
rm -f " ${output_path} "
101
+
102
+ emit_completion_command
72
103
}
73
104
74
105
main
You can’t perform that action at this time.
0 commit comments