ChrisTitusTech / Debian-titus

Debian customizations from Chris Titus Tech
GNU General Public License v3.0
414 stars 152 forks source link

Import .use-nala files instead of adding their code to bashrc files #82

Closed ghost closed 1 year ago

ghost commented 1 year ago

also made it a seperate script to prevent bloating the install script.

While testing my changes, I got my .bashrc overwrited cause i forgot to add one more > :smile: Luckily I was opened ~/.bashrc in nano on another terminal tab before getting it overwrited.

I think importing .use-nala is a good idea because if someone run the install script more than once, .bashrc can get messed up.

Old code was adding the code to .bashrc that configures bash to use nala in every time install script is ran and this was not good. Now, it'll check existence of .use-nala file and it will not re-add the code to .bashrc if it exists.

# For User
$ cat .use-nala 
apt() {
  command nala "$@"
}
sudo() {
  if [ "$1" = "apt" ]; then
    shift
    command sudo nala "$@"
  else
    command sudo "$@"
  fi
}

$ cat ~/.bashrc
...
if [ -f "/home/nxjoseph/.use-nala" ]; then
        . "/home/nxjoseph/.use-nala"
fi

# For Root
# cat ~/.use-nala
apt() {
  command nala "$@"
}

# cat ~/.bashrc 
...
if [ -f "/root/.use-nala" ]; then
        . "/root/.use-nala"
fi