Lazy Bash Auto Install
Sometimes you have a dotfile repository and need an auto installer.
I always like to execute bash with
bash -x
for maximum debugging goodness
My dotfiles repo consists of both regular files and directories. I’m going to loop through both and run a subroutine on them, for ultimate complexity.
Artifically constructing a for loop here is easy, and it’s going be be simpler to just manually keep track of files. So lets say you have profile
, screenrc
, and vimrc
,
1 2 3 4 |
|
Don’t forget you have to declare your subroutines/functions before they are executed
And now the sub_file
can just unlink some each file (note it still has access to the $f
variable)
1 2 3 4 |
|
Taking advantage of the built-in $HOME
and $PWD
I believe is a good practice.
Ok, cool, you’re done. For directories, use the -d
flag to check if the directory exists or not.