Linux, Dropbox and a really long .bashrc file

So lately I've been reworking my Linux configuration structure a bit. Since I've installed Ubuntu in a virtual machine on my desktop PC, I put my .bashrc my .xinitrc and .Xsession config files in my dropbox. Such that I could transfer them from my Arch Linux install on my laptop, to my desktop in an easy way. However, I changed my mind of just copying in the configuration files and maybe lose them if my installs get broken. I decided to symlink them instead! (YEEEY SYMLINKS). For those of you who don't know what a symlink is you can imagine it as a shortcut. In an environment you might have a program file on your desktop that you can use to start an application. For example you might have an icon for launching a browser on your desktop. The actual browser application is not on the desktop - it's just something for the user to easily launch the browser. In the same way I've symlinked my configuration files. The Linux system expects them to be in /home/user/.configfile. Therefore I've made a "shortcut" from /home/user/.bashrc to /home/user/Dropbox/Linux\ configuration\ files/.bashrc.

The main reason for this setup was that I would always have a backup of my configuration files such that I would not have to waste a lot of time writing them again. Another thing is that whenever I make a change on one of my installs, it will get updated on my other Linux installs. This is actually quite useful, such that you keep your aliases on every install, such that you don't have to sit and get confused by a missing alias.

A downside is that desktop environments are using different lock commands and Linux distributions might not use the same package manager. Therefore there was a need for me to write up some functions. Underneath I will show a function making available the "update" command in terminal.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function update {
    if [ -f "/etc/arch-release" ];
    then
        #Arch Linux case
        printWithColor $Blue "Running Arch update\n"
        sudo pacman -Syu
        printWithColor $Blue "Finishing system update\n\n"
        if [ -f "/usr/bin/packer" ];
        then
            #if packer is installed run the packer AUR update
            sudo packer -Su
            printWithColor $Blue "Finishing AUR update\n"
        fi
        printWithColor $UGreen "Update finished!\n\n"
    elif grep -q "Ubuntu" "/etc/issue";
    then
        #Ubuntu case
        printWithColor $Blue "Running Ubuntu update\n"
        sudo apt-get update
        sudo apt-get upgrade
        printWithColor $UGreen "\nUpdate finished!\n\n"
    else
        #Else tell that the update
        #command could not be found for the OS
        printWithColor $BRed "Could not determine OS\n\n"
    fi
}

Here I check whether the current running terminal is running in an Arch Linux or Ubuntu environment and do the appropriate system update using the package manager. The print with color is doing what you expect. It takes as input a color and a string and then prints the string in that color and afterwards resets the color to white. I think this is quite smart to be honest, that a common update command is found for every install that I have (although I only support Ubuntu and Arch at the moment)

Hope some of you can use this for something. I just wanted to show how easy I find this setup and think it can be useful for others as well.

- Archi

Category(s): Everyday life
Tags: , , , ,

Comments are closed.