-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support linking different files on different systems #77
Comments
I'd be in favor of this or any other system to have platform-specific linking of files. 👍 |
I'm also in favor of this. The only downside is if there are any conflicts with existing castles. I think we need to update homeshick to use semantic versioning as I lay out in the second part of this #95 (comment). |
@ngaloppo in response to you comment here: #95 (comment)
It is quite unlikely, but what if I had a dir in a castle at |
I'm definitely in favor of this. I just think that we need a mechanism to let homeshick users know that there are potential breaking changes in the latest update. |
Makes sense, although unlikely for any existing users of homeshick. While On Thu, Apr 24, 2014 at 9:42 AM, Daniel Searles [email protected]:
|
A few thoughts:
|
@ngaloppo I'm replying to this #95 (comment) here since this is the feature we're talking about.
This feature #77 is quite a bit more robust than how I use multiple castles. I don't have an elegant solution to the original use case, but I do have files that I only want on a single os or another. For example I have a main
I have the linux bashrc in a linux castle and the mac bashrc in a mac castle. The local bashrc is an option for me to have machine local bashrc overrides that don't get added to source control. |
I agree, but this is also about sending a message to users that we really care about not breaking their setup. If they are warned about potential breakage, no matter how small, it builds trust.
Me neither, but for other reasons. The dependency chain is very long now and it goes like this: |
While I agree that
I was thinking the exact same thing, that approach is a lot more extensible, you can even add an environment var test like `foo#env_SHELL=/bin/zsh
Looks interesting. It can definitely serve as inspiration :-) |
Maybe I missed it, but what form of escaping is being proposed? I'm not sure I really buy the need to escape if the delimiter is fairly unique. Doubling a character is a somewhat time-honored way of doing that, e.g. identifiers of the form |
Woops, that was discussed in #95. It's basically just saying that we could use
Why settle for less when you can have it all with the same amount of effort? |
I'd argue that |
Instead of overwriting the users .bashrc I would rather go the way to add a .bashrc.homeshick which is included to the users local .bashrc so it doesn't break anything on user side. In my own project I use this:
|
@squaresurf That sounds like a good way to do it. I was wondering why you think that the proposed feature will be better than what you have today. |
@NemesisRE I'm not sure what you're talking about. I wasn't proposing any changes to homeshick that would affect any bashrc for users of homeshick. I was just giving an example for @ngaloppo how I use os specific repos with the current version of homeshick. @ngaloppo #77 is quite a bit more flexible than what I've been doing. It allows for different paths for the same file depending on the os whereas my scenario only really works for different files for different operating systems. |
@squaresurf I see. Was not meant as an offence, just an idea if you wanted to change that behavior. Bash-it had overwritten my .bashrc this is why I was alerted ;) |
@NemesisRE I'm sorry if I came off as offended. That wasn't the case at all :) I just wanted to be clear that I wasn't suggesting mucking with users |
That would lead to an inconsistent implementation where the interface for linking is less predictable. We need regularity - an empty filter (e.g.
Backslash is used pretty much everywhere in unix to escape things with. Windows is the odd one out here. |
I support changing # to two #'s, just in case someone number files with #'s as pointed out above. I have another system for handling bashrc/bash_profile though, which works similarly but with directories instead of #'s. If you're interested to see how, check out homesick-bumod (shameless plug). |
Backslash is used a lot in string data, but filenames aren't really normal strings. I don't plan to have to escape anything, so I guess it doesn't really impact me, but I would still strongly advise against using backslash this way. For example, Cygwin users would be unable to escape using backslash, since they can't create files with backslash in them (maybe there's a way around that, but they can't in the default configuration). |
I would like this feature as well, as I'm using multiple systems myself, I really don't care what you choose as delimiter, as long as you make sure that you can escape it somehow, and sure make it obscure so you don't run into it in every day usage. |
@iron8core Why do you have two separate systems? Couldn't you handle bashrc/bash_profile through the same system as proposed here (and implemented in your fork)? |
@ngaloppo On 27 April 2014 08:55, ngaloppo [email protected] wrote:
|
@iron8core Makes sense! |
@jjlin brings up a good point:
I agree that filenames aren't strings like in other programs that you would escape a character with. @andsens are you opposed to using a different escape character such as the backtick (`) character? |
This is a non-issue, since windows support is not going to happen (see #99).
But you do escape whitespace and special characters on the commandline with backslash, it's not entirely the same, but I think it's what people are used to.
That would be even more annoying :-) You'd have to escape that character itself in the shell (backtick launches a subshell like I think we need to bring parts of the discussion to a close. DelimitersSo far I have only seen @jjlin disagree with the choice of Escape charactersApparantely homeshick works on Cygwin (I honestly had no clue :-)), so the backslash will definitely break stuff and there's no need to do that. Short of smashing a random key on the keyboard maybe we can find something that still makes semantic sense? FiltersFilters are Keys should be insensitive and values should be case sensitive (just an idea, open to suggestions). Possible filter keys
ChallengesThe problem from #28 (Unlink deleted files) rears its head a second time. homeshick should check if unmatched files with filters are symlinked and remove those symlinks (e.g. an env variable changed). I have put all of this in the first message of the issue so people can easily find it. |
Regarding escape characters, just a thought, but there is some precedent for doubling a character to escape it. So maybe Regarding And maybe shorten |
Regarding the filter keys: we may want to consider those to be case-insensitive substring matched, rather than exact matched. So |
Doh! @andsens you're right that the backtick escape character would be extremely annoying! I can't believe I overlooked that. This is a great example why its good to talk things through first :) I was thinking that it kinda looked like a short backslash. Thus helping readabililty. I'm kinda at a loss as to what we should use as an escape character though. It doesn't look as pretty but does @andsens thank you for boiling down the discussion. I agree with your decisions so far 👍 |
We will need to escape
Agreed, I think some normalization is in order here.
Sure, lets do that.
I think normalization is the better path to take here, substring matching is not what the user would expect when using
True. It looks like you only need to escape EDIT: Updates to summary + The escape character will be used for all three special characters (`#`, `=`, `,`) and for the escape character itself.
+
+ When would the escape character need escaping? Only when it preceeds one of the other special characters?
- * `Windows` (or is `Cygwin` better?)
+ * `Cygwin`
- * `hostname`: Hostname of the system
- * `username`: Username of the executing user
+ * `host`: Hostname of the system
+ * `user`: Username of the executing user |
I like |
Is anything blocking this or still being decided? |
The "Challenges" section still needs a solution, but that's about it. |
I've created a simple proof-of-concept version based on master (as of today). See my fork at https://github.com/iron8core/homeshick/tree/master. I've only modified symlinking and added a "homeshick symscores" function, so anything else will probably fail. |
Good point about the conflicting filters! I like your solution. Though I wonder if there is any way to make this simpler. |
Could you give an example of how it would work? I've pushed new changes that simplifies the changes to the symlink function as well as some additions. And how about handling directories? It's hard to know if a directory is actually the correct one when it's not a link. |
I'm currently on vacation, so I'll not really be able to code properly until I'm back at the end of the month.
On a linux machine named |
Hi there. Anything that can be done to get some progress on this issue? |
Short of sending a PR, a pseudo code suggestion for how the filtering might be implemented would be cool. I have something of an idea on how to do it, but maybe there are others that have something really short and sweet to solve it. I have been busy with a few challenges in the linking code, which is exactly where we would need to add code to implement this issue. It is rather stable now I'd say, so there's a chance I might start on an implementation. |
Wouldn't @iron8core's implementation be a good start? |
Yes. It would be, note that I have written a spec/summary in the first comment if this issue. I'm updating it until everything is clear. |
I think @iron8core's solution with a scoring mechanism is a neat solution, but I am wondering whether it wouldn't be simpler to just rank the filters in absolute terms. I'd keep the ranking from @iron8core's fork and then make ordering of the filter values significant. What should homeshick do when there are two files on different paths where both match and they are located in folders that both match as well? My suggestion would be that the parent dir overrides all, so whichever directory wins gets to link its files, while the files in the losing dir are ignored regardless of whether they'd win against files in the winning dir. Also, I thought of a new filter: |
I've been busy with other stuff lately so haven't had time to try and adapt the changes according to the summary draft (also, as Debian <= Wheezy users might have noticed my fork wouldn't/won't(?) work due to using associative arrays). Just so I'm following, should the "score" (for lack of a better term) be calculated from the entire path or for one file/dir only (for Linux etc systems, everything between two slashes)? I'm not sure about the use cases for all these examples, but just so we're clear on everything. Example 1: Example 2: But, if let's say only the conditions on .folder and folder2 match (domain and hostname), should we link to .folder/folder2? It would allow for a hierarchical structure of dirs/files, but would probably complicate things too much. Example 3: At the moment I'm actually using two separate mechanisms to handle my dotfiles. First my homeshick fork (which at the moment works good enough for me but ugly code, and the #cmd-condition sounds awesome), and then another level of scoring for my zsh config files that are cached and sourced also according to pretty much the same conditions as in homeshick (but I wrote that in zsh, not bash). |
We appear to be heading deeper and deeper into the rabbit hole now. Some of the examples above are nearly incomprehensible to anyone who is not intimately familiar with the inner workings of this feature and its scoring system. I can't imagine how difficult it is going to be to document and clearly explain to end-users. How about this as an alternative. Inside each castle, there's users can create a special dotfile (e.g. Then, users execute a command like Then, when homeshick does its linking, it links all files that don't end in an extension that is in the castle's You could also do Then we don't need to worry about naming variables and escape characters in filenames. They can use |
I don't agree. The reason the examples are getting more and more complicated is because we are exploring edge-cases - to figure out how homeshick should behave in the extremes. Your suggested solution works fine when you can group setups and they don't overlap. The existing solution allows for much more freedom in that regard and does not require users to learn yet another command -- though I must admit that it is otherwise an elegant solution, the control over which files are linked is much more explicit than in the current solution. On a different note: @iron8core
I don't think so, linking I have a simpler solution to the ranking by the way (spurred by @mrmachine's comment). How about we forget all about the ranking and simply pick the first file that matches lexicographically? Isn't a conflict so much an edge-case that we would rather have the user change his filters if he wants another file to be linked? Also: Conflicting files: We could instead of picking a file when two or more filters match simply throw an error and tell the user to fix the situation, it might force the user to configure the castle in a more sane manner (i.e. use mutually exclusive filters for the same filename instead of relying on some scoring mechanism or alphabetical ordering). Hm, I rather like that last part. It encourages user to not complicate things too much in their castles. |
Sure, having a system such as the one being discussed is more powerful and flexible. And we might be talking about edge cases, but the complexity of the system is what allows all these edge cases to occur. Power and flexibility come at a cost. A simpler system will have far fewer possibilities for edge cases to occur, and will be far easier to document and easier for users to learn. It should also easily cover the most common use-cases. It can still work for overlapping groups. Just name your file with multiple extensions. I think this is a good thing. Seriously, who not only has so many environments to manage, but also regularly has so many new environments to manage, that they need homeshick to automatically work this stuff out? And if they do, what happens when people want to start adding in exceptions? E.g. link this file on |
@iron8core has forked the repo and implemented a nifty feature: linking based on the machine os. Files are disambiguated by appending
#OS
to them.This would make a lot of sense for cross-platform deployments of e.g. Sublime Text, which stores its config in
$HOME/Library/Application Support/Sublime Text 3
on OSX and in$HOME/.config/sublime-text-3
on Linux.That would allow you to create a repo like so:
He also added hostname disambiguation, but I think that would kill the simplicity of it.
The downside of course is that any hashmarks in folder names could clash with this feature.
Any comments?
EDIT:
Summary
Delimiters
So far I have only seen @jjlin disagree with the choice of
#
as a delimiter. The alternative was lifted from the ClearCase VCS, where the argument was also made for a two-character delimiter. Since there will be a need for an escape character regardless, we should stick to a single character delimiter and in the absence of arguments against#
, I say we use it.Escape characters
Apparantely homeshick works on Cygwin (I honestly had no clue :-)), so the backslash will definitely break stuff and there's no need to do that. Short of smashing a random key on the keyboard maybe we can find something that still makes semantic sense?
The escape character will be used for all three special characters (
#
,=
,,
) and for the escape character itself.When would the escape character need escaping? Only when it preceeds one of the other special characters?
Filters
Filters are
AND
'ed and separated with commas. Key and value are separated by a=
. The same escape character for,
and=
should also be used for the delimiter.Keys should be insensitive and values should be case sensitive (just an idea, open to suggestions).
Possible filter keys
cmd
: whether a command is availableos
: the operating system. Possible values:Linux
OSX
Cygwin
BSD
(both FreeBSD and OpenBSD, any others?)host
: Hostname of the systemuser
: Username of the executing userenv_$varname
: Environment variable valuesFilter conflicts
@iron8core discovered and fixed another problem (see comment below): What to do when two files with different filters but the same name match?
Possible solutions:
Challenges
The problem from #28 (Unlink deleted files) rears its head a second time. homeshick should check if unmatched files with filters are symlinked and remove those symlinks (e.g. an env variable changed). This may however be something that should be discussed in issue #28.
The text was updated successfully, but these errors were encountered: