Live data from Hacker News

Dotfile madness

0x46.net

141–150 of 534 posts

Re: Dotfile madness

#141
post #137

Oddly I feel completely the opposite about this topic. I think dot files in your home directory are exactly the way to go. Using the XDG standard leaves you with whatever the distro decides is the correct location for these files. While their recommendation is all in the home directory, I wouldn't put it past some of these distro developers to make some crazy /var/users/{uid}/config directory. This is important when…

So rather than use a standard that allows you to override it simply by changing some environment variables, you think that hardcoding a specific path is a better solution?

Definitely a unix developer.

Re: Dotfile madness

#142
A lot of other people have made some fantastic points here, so I won't harp on "putting random crap in ~/ bad!" any further.

However, since it has not been mentioned, I would like to shout out to the Python "appdirs" module[1], which neatly solves this issue for those writing programs in Python with minimal effort. The best part is that it uses the platform's native standards, so XDG on Linux, plus whatever macOS and Windows call their implementations.

Sadly I am not aware of comparable options for other programming languages. I think having high-quality easy to use libraries for this sort of thing would go a long way.

1 - https://pypi.org/project/appdirs/

Re: Dotfile madness

#143
post #35

Earlier quoted context omitted.

That's an intellectually lazy thought. If everyone had that attitude we wouldn't have modern society at all (grow your food, don't expect someone else to grow it for you).

Linux has been and is a tinker OS for folks who know wtf they are doing. As time progressed it has become easy enough folks who dont know what they are doing can use many of the distributions. Those folks are destroying what used to be a wonderful intelligent linux community.

You realize this is the definition of gatekeeping, right?

Re: Dotfile madness

#144
post #88

Earlier quoted context omitted.

Sounds like you might need to hook rename() if you'd like to add that feature too, but I would still say it's straightforward.

The way most editors save a file is like this: f = open("the_file.new") write(f, new_contents); close(f); rename("the_file", "the_file~"); rename("the_file.new", "the_file"); So the old file is never modified, it's renamed to the backup copy, and an entirely new file is created to take its place. This has a number of advantages, but does not play well with any extended info the old file used to have, unless they are…

I see a lot of saves work like this:

    f = open( "the_file.new.$$" );
    write( f, new_contents );
    close( f );
    rename( "the_file.new.$$", "the_file.new" )
If not implemented like this, then something that attempts to read "the_file.new" may get partial contents, normally truncated along the file system block size.

Backups often take place, too, like you mentioned, depending on editor.

Re: Dotfile madness

#145
I personally detest the whole XDG thing but lots of non-XDG applications are guilty of littering the home directory. For example, every time I use the Less pager, it creates a .lesshst file (fixable by setting "LESSHISTFILE" to "-"). Vim creates .viminfo files so I had to create an alias to it where vim equals "vim -i NONE".

Re: Dotfile madness

#146

To me, the real problem is not the dotfiles, but the regular (i.e. non-hidden) files that applications surreptitiously create in my home folder. (Which the author does mention as being particularly bad.) dotfiles in the home folder are not a new thing on Linux (e.g. .bashrc, .profile, .emacs, etc.), even if it would be better if more applications used the XDG folders. And if I don't see them when I "ls", they don't b…

I use ubuntu 18.04 (kde) and my snap folder is /snap I don't know how I did this.

Do you just have a /snap directory and no $HOME/snap? Normally, snap creates /snap for the binaries (shared among all users) and $HOME/snap for the per-user configuration/data files.

Re: Dotfile madness

#147
My project cihai (http://cihai.git-pull.com/) and unihan-etl (https://github.com/cihai/unihan-etl) both use the XDG specification.

The reason I like it is it provides directories to use across platforms (edit: Not sure about Windows), relative to the user. Since the applications download a file (UNIHAN database [1]) to bootstrap, we want to store it in the user's files, not the systems. The other thing I do that's helpful is using sqlite (which is often built with Python).

This combination gives a database, and a place to store configuration, downloaded/built files, in an organized way across systems.

The nice things XDG "standardizes" which I'm using:

$XDG_DATA_HOME defines the base directory relative to which user specific data files should be stored. If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used.

$XDG_CONFIG_HOME defines the base directory relative to which user specific configuration files should be stored. If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used.

$XDG_CACHE_HOME defines the base directory relative to which user specific non-essential data files should be stored. If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used.

Why the implementation is helpful:

It defines a common directory for cache/data/config files, with applications inside them, e.g. ~/.config/i3, ~/.config/tmuxp, rather than adding more stuff to ~/.i3, ~/.tmuxp. When standards aren't being followed, programs end up storing their configurations / data / etc all over.

Another thing is it defines directories relative to the user themselves and for the system files. Dotfiles may imply configuration / artifacts in the users home directory, it doesn't have. The thing I like is I can check for configuration in user files (for instance ~/.gtk-3.0/), then fall back on checking the system files (/etc/gtk-3.0).

The benefit of user files is they're writable out of the box, so if there's going to be any file generated that the user needs to keep (like an unzipped version of UNIHAN) that can be cached so they don't have to download it again.

(XDG Link: https://specifications.freedesktop.org/basedir-spec/basedir-...)

[1] https://www.unicode.org/reports/tr38/

Re: Dotfile madness

#148
post #60

Earlier quoted context omitted.

A general tagging mechanism, reasonably supported across filesystems , would be great to have. Not only for media collections. It's not easy to implement nicely, though.

There's an entire research field dedicated to the information flow control which could solve just that (if it were actually used). In my research team, we used a tainting tracing mechanism to understand the behavior of malware. Basically, we installed a malware on a clean phone and we then traced all information flow originating from the APK to processes, to files, to sockets, etc. It helped reverse-engineering the m…

Any interesting links to papers?

Re: Dotfile madness

#149
post #137

Oddly I feel completely the opposite about this topic. I think dot files in your home directory are exactly the way to go. Using the XDG standard leaves you with whatever the distro decides is the correct location for these files. While their recommendation is all in the home directory, I wouldn't put it past some of these distro developers to make some crazy /var/users/{uid}/config directory. This is important when…

So rather than use a standard that allows you to override it simply by changing some environment variables, you think that hardcoding a specific path is a better solution? Definitely a unix developer.

I agreed, right up until the unnecessary second paragraph!

Re: Dotfile madness

#150
I tend to carry $HOME around with me when I change systems. When I ls -Alr it was like opening up a time capsule, or a hope chest. The first 4 pages on a 23 line terminal had file and directory names for content old enough to buy liquor in all 50 states, old friends like .cshrc, .addressbook, .X11Startup, .nofinger, amd.home, .zirconrc, dot.signature, aub.home, and so on.
Post reply on HN