How do I add a new dotfile with Dotbot? - bash

I'm trying to version my dotfiles on Linux via Dotbot, using init-dotfiles as initial setup. It worked great, but how do I add a new file to my .dotfiles repository?
In my case, I created a .bash_aliases file in my home folder.
It wouldn't make sense to run the init-dotfiles script and go through he whole setup process every time I create a new dotfile.

You could still run the script in verbose/preview mode, just to see the commands it runs
./init_dotfiles.sh verbose-config preview
Then you will be able to deduce the git command to run in order to add your new file (and future new files) to the dotfile repository.

That's correct, you shouldn't run the init-dotfiles script again.
To add a new dotfile, at a high level, you'll need to:
move the dotfile from the original location (e.g. ~/.bash_aliases) to the dotfiles repository (e.g. ~/.dotfiles/bash_aliases)
update your install.conf.yaml to specify how to symlink the file
add both the new dotfile (bash_aliases) and your install.conf.yaml to a new git commit

Related

enable certain commands in root level of a project without writing script nor manual setup for local machine

Currenly, if I want to run something like start in a project, let say /myproject I have to make a new bash file and name it like start in order to have some sort of command like ./start to work properly.
But I want to do is somehow I can add some sort of config file into the root folder to run all different kinds of command without ./ needed and simply start or anything else as I want to make, without having to create whole bunch of bash files.
Is there a way to setup it so if someone just pull a git repo down can just have it?
Assume that the git repo also contains package.json or maybe gradle.
However, I dont want to use npm run xxx or gradle xxx its just too much typing...
Sorry if I am asking too much for a setup lol

how to configure cygwin Local Package Directory

I have to change my cygwin Local Package Directory, which happen to be earlier as C:\Users\username\Downloads.
Folders like http%3a%2f%2fcygwin.mirror.constant.com%2f are all in place in my new directory for Local Package Directory.
How to do that? (I cannot find, where cygwin stores the config.)
Running setup from new location tries to install all over again instead from continue using earlier packages from the internet.
The information is on /etc/setup/setup.rc
$ head setup.rc
last-cache
e:\downloads\cygwin_cache
last-mirror
http://mirrors.kernel.org/sourceware/cygwin/
net-method
Direct
last-action
Download,Install
mirrors-lst
....
Please note that setup just propose the settings based on last run but you can always change typing new values.

zsh/mercurial help on every command

Every command I make in terminal while in zsh I get the mercurial help appended.
Example:
$ ls
Applications Developer Library Pictures VirtualBox VMs
Consensus Documents Movies Projects
Desktop Downloads Music Public
haaduken at nachi in ~Mercurial Distributed SCM
basic commands:
add add the specified files on the next commit
annotate show changeset information by line for each file
clone make a copy of an existing repository
commit commit the specified files or all outstanding changes
diff diff repository (or selected files)
export dump the header and diffs for one or more changesets
forget forget the specified files on the next commit
init create a new repository in the given directory
log show revision history of entire repository or files
merge merge working directory with another revision
pull pull changes from the specified source
push push changes to the specified destination
remove remove the specified files on the next commit
serve start stand-alone webserver
status show changed files in the working directory
summary summarize working directory state
update update working directory (or switch revisions)
use "hg help" for the full list of commands or "hg -v" for details
$
I have absolutely no idea why. Any ideas how I can stop this? A lot of people are saying alias, but hg isn't in my alias list at all.
Did you add a Mercurial command to your PS1 variable? Some people do this, to display the current branch or bookmark.
What does 'echo $PS1' show?
It's possible you added an incorrect Mercurial command there, which results in printing the help message.

Using bash to automate dotfiles

I want to create my own automated dotfiles folder. (I'll be using git to use version control on my dotfiles, but that's irrelevant for the question)
What i simply want is to symbolically link all the files and folders in ~/dotfiles to my home folder. Being not good at all with bash I can't do this. Please help me with this.
I would also appreciate the following features if possible.
Folders are only shallowly linked
My files could be in the dotfiles folder without the actual dot in the file-name (like ~/dotfiles/vimrc rather than ~/dotfiles/.vimrc)
It should be able to ignore some files, like my .git file which are stored in the same folder
Of course if you already know a service providing this, that is at least as good as providing some do-myself commands. Note how I specifically want it to be bash or something that most likely exists on all unix machines (so i guess commands using g++ are fine).
Give this a try:
ln -s ~/dotfiles/* ~
There shouldn't be any need for a loop. Of course, you can use find if you need something recursive.
Edit:
To make the destination files hidden:
for f in ~/dotfiles/*
do
ln -s "$f" "$HOME/.${f##*/}"
done
I am not sure if I'm getting the question right, but if you looking for symlinks of dir-content, try
for f in `ls -1 .dotfiles`
do
ln -s .dotfiles/$f ~/$f
done
maybe that already does the trick
For the sake of managing dotfiles, I really like Zach Holman's approach. I've made the same thing with my dotfiles which you can find it here :)
https://github.com/rhacker/dotFiles
Maybe you are looking for a dotfiles manager, I will recommend you to check DFM (dotfiles manager). DFM addresses the problem you have in a very clean way:
Here is my dotfiles selection using dfm: vicente's dotfiles
Github official repository DFM site
Atlassian has a tutorial on using a git work tree instead of symlinks. The approach uses:
a bare git repository in a side folder (such as $HOME/.cfg or $HOME/dotfiles), and
a config bash alias to execute git commands that manage the configuration files.
For instance, you can run config status to check which files have been modified, config checkout to get the files in the repository and config commit to update the repository. It requires only git and the bash.
I was also looking for some way to set up a new machine in a minimal number of steps, after spending some time I found that almost all the developers use git to store and share these files and symlinks to sync them.
Well, symlinks works, but it isn’t the best way to sync your local files to the git repository. There is a much better solution to this, written by people at Atlassian – https://www.atlassian.com/git/tutorials/dotfiles.
So, to git bare repository is the best and most elegant way to sync your files with your remote copy create a bash script to automate installation and set up.
Managing dotfiles
The trick to managing these dotfiles is by creating a bare git repository. If you are starting from scratch and have not tracked your dotfiles before, make a bare repository in the $HOME directory.
git init --bare $HOME/.dotfiles
Just to make it easier to use we’ll alias this to dotfiles which we will use instead of regular git to interact with our dotfiles repository.
alias dotfiles="/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME"
Now we are good to track our dotfiles using the dotfiles command, some of the examples are:
# to check the version history
dotfiles log
# to check the status of the tracked and untracked files
dotfiles status
# to add a file for tracking
dotfiles commit .vimrc -m ".vimrc added"
# push new files or changes to the github
dotfiles push origin main
Use Cases and Advantages of dotfiles
This method of managing and sharing has various advantages some of them are listed below.
Easy setup
Set up of a new machine can be a time consuming task, but with this method we can to use our personalized configs in under a minute. We just need to clone the repository and source the .bashrc or .zshrc file.
git clone --bare https://github.com/<username>/dotfiles.git $HOME/.dotfiles && source ~/.zshrc
Versioned dotfiles
Best for experimenting with new configurations and keep the change history (Basically all the pros of using git)
# to check the version history
dotfiles log
Share on Multiple devices
Share the same configs of multiple devices with minimal changes using branch, create a branch for your new machine, example:-
# Create configurations specific to your aws machines
dotfiles checkout -b aws
Profiles for dotfiles
Create configs based on your environment using branch, create a branch and configure according to you work env.
# Manage multiple profiles - check out to the work profile
dotfiles checkout work
I also use this way to sync and store my dotfiles, see my dotfiles repository and can read at Storing dotfiles with Git where I wrote about managing for multiple devices.
You could also use dotfile_manager. It allows you to set up a custom path for every symlink you want to create. So with this, you can easily ignore some files and add the . as a prefix to other files.
In your case you would setup the config file dotfile_manager.yaml to contain
symlinks:
- vimrc: ~/.vimrc
Full disclosure: I am the author of this package and use it every day.

Extra Copy of New Rsync Files

I am attempting to mirror a directory on a remote server using rsync. However, I would like a copy of all newly created files to be stored in a separate directory on the local machine.
For example, if a new file is added on the remote server, I would like it to mirror regularly (for example, to ~/mirror), but save an additional copy of only the new file in another folder, (for example, ~/staging). To be clear, only the new files should appear in staging.
My first approach was to allow rsync to update the timestamps, and then use that to make a copy. However, I would now like to preserve timestamps.
Can anyone provide ideas on a simple approach? I am open to use of additional utilities other than rsync.
You might consider making hardlinks in the extra directory.
ln --force --target-directory=~/staging ~/mirror/*
Edit:
If this is a Linux system, incron will trigger on inotify events and would allow you to make copies of files as they are added to a directory you specify.

Resources