mirror of
https://github.com/ChrisTitusTech/mybash.git
synced 2026-04-07 04:58:26 +00:00
Update setup.sh to correctly detect home directory
Previously the script sometimes incorrectly used /root as the home directory.
This commit is contained in:
12
setup.sh
12
setup.sh
@@ -87,11 +87,13 @@ installStarship(){
|
||||
}
|
||||
|
||||
linkConfig() {
|
||||
## Get the correct user home directory.
|
||||
USER_HOME=$(getent passwd ${SUDO_USER:-$USER} | cut -d: -f6)
|
||||
## Check if a bashrc file is already there.
|
||||
OLD_BASHRC="${HOME}/.bashrc"
|
||||
OLD_BASHRC="${USER_HOME}/.bashrc"
|
||||
if [[ -e ${OLD_BASHRC} ]]; then
|
||||
echo -e "${YELLOW}Moving old bash config file to ${HOME}/.bashrc.bak${RC}"
|
||||
if ! mv ${OLD_BASHRC} ${HOME}/.bashrc.bak; then
|
||||
echo -e "${YELLOW}Moving old bash config file to ${USER_HOME}/.bashrc.bak${RC}"
|
||||
if ! mv ${OLD_BASHRC} ${USER_HOME}/.bashrc.bak; then
|
||||
echo -e "${RED}Can't move the old bash config file!${RC}"
|
||||
exit 1
|
||||
fi
|
||||
@@ -99,8 +101,8 @@ linkConfig() {
|
||||
|
||||
echo -e "${YELLOW}Linking new bash config file...${RC}"
|
||||
## Make symbolic link.
|
||||
ln -svf ${GITPATH}/.bashrc ${HOME}/.bashrc
|
||||
ln -svf ${GITPATH}/starship.toml ${HOME}/.config/starship.toml
|
||||
ln -svf ${GITPATH}/.bashrc ${USER_HOME}/.bashrc
|
||||
ln -svf ${GITPATH}/starship.toml ${USER_HOME}/.config/starship.toml
|
||||
}
|
||||
|
||||
checkEnv
|
||||
|
||||
Reference in New Issue
Block a user