Use hostname as default for computr name

This commit is contained in:
Rezart Qelibari
2022-04-04 17:32:45 +02:00
parent 0fd4ed6479
commit b96fe10a72
2 changed files with 17 additions and 1 deletions

View File

@@ -1,7 +1,14 @@
#!/usr/bin/env zsh
function getDefaultFullname() {
function getComputerName() {
local moduleAnswer
local computerName="`scutil --get ComputerName 2> /dev/null`"
getModuleAnswerByKeyRegEx '_hostname$' && computerName=$moduleAnswer
print -- $computerName
}
function getDefaultFullname() {
local computerName="`getComputerName`"
lop -- -d 'Default full name based on current computer name is:' -d "$computerName"
print "${computerName}"
}

View File

@@ -14,6 +14,15 @@ function configureLogging() {
lop setoutput -l ${level} ${output}
}
function getModuleAnswerByKeyRegEx() {
local key value
local searchRegEx=$1
for key moduleAnswer in ${modkey:^modans}; do
[[ $key =~ $searchRegEx ]] && return 0
done
return 1
}
function checkCommands() {
local cmd
for cmd in ${(k)cmds}; do