Add profile support for mac
This commit is contained in:
parent
840a410ff2
commit
ffe0b8f65b
@ -27,14 +27,6 @@ kickstart.mute() {
|
||||
return $?
|
||||
}
|
||||
|
||||
kickstart.add_to_profile.d() {
|
||||
file=$1
|
||||
[ ! -f files/$file ] && kickstart.info "File files/$file not found" && exit 1
|
||||
|
||||
cp files/$file /etc/profile.d/$file
|
||||
grep -q $file /etc/zshenv 2>/dev/null || ( echo "[[ -f /etc/profile.d/$file ]] && source /etc/profile.d/$file" >> /etc/zshenv )
|
||||
}
|
||||
|
||||
kickstart.command_exists() {
|
||||
which $1 >/dev/null 2>&1
|
||||
}
|
||||
|
32
kickstart/recipes/kickstart/profile.sh
Normal file
32
kickstart/recipes/kickstart/profile.sh
Normal file
@ -0,0 +1,32 @@
|
||||
kickstart.profile.add_to_profile() {
|
||||
local file=$1
|
||||
[ ! -f files/$file ] && kickstart.info "File files/$file not found" && exit 1
|
||||
|
||||
local profile_d=`kickstart.profile.profile.d.location`
|
||||
mkdir -p $profile_d
|
||||
|
||||
cp files/$file $profile_d/$file
|
||||
|
||||
kickstart.profile.source_on_configuration_file $file $profile_d `kickstart.profile.location.zsh`
|
||||
kickstart.os.is Mac && kickstart.profile.source_on_configuration_file $file $profile_d `kickstart.profile.location.bash`
|
||||
}
|
||||
|
||||
kickstart.profile.profile.d.location() {
|
||||
kickstart.os.is Ubuntu && echo /etc/profile.d
|
||||
kickstart.os.is Mac && echo ~/.profile.d
|
||||
}
|
||||
|
||||
kickstart.profile.source_on_configuration_file() {
|
||||
local file=$1
|
||||
local profile_d=$2
|
||||
local configuration=$3
|
||||
grep -q $file $configuration 2>/dev/null || ( echo "[[ -f $profile_d/$file ]] && source $profile_d/$file" >> $configuration )
|
||||
}
|
||||
|
||||
kickstart.profile.location.zsh() {
|
||||
[ `whoami` = root ] && echo /etc/zshenv || echo ~/.zshenv
|
||||
}
|
||||
|
||||
kickstart.profile.location.bash() {
|
||||
[ `whoami` = root ] && echo /etc/profile || echo ~/.bashrc
|
||||
}
|
Loading…
Reference in New Issue
Block a user