Open andsens opened 10 years ago
I like this idea - I have noticed the output gets a bit mangled in the bats unit tests as well. So, you just want a raw stream of files + action taken by homeshick streamed to stdout if ! [[ -t 1 ]]
? I could see something like a list with two columns:
identical .bash_profile
identical .bashrc
identical .bashrc.d
identical .bashrc.d/functions
identical .bashrc.d/functions/completion.sh
identical .bashrc.d/functions/gcd.sh
identical .bashrc.d/functions/path-manip.sh
identical .bashrc.d/functions/smart-alias.sh
identical .bashrc.d/functions/ssh-login.sh
identical .bashrc.d/functions/update.sh
identical .bashrc.d/platform
identical .bashrc.d/platform/cygwin.sh
identical .bashrc.d/platform/darwin.sh
identical .bashrc.d/platform/linux.sh
identical .bashrc.d/topics
identical .bashrc.d/topics/aliases.sh
identical .bashrc.d/topics/bash.sh
identical .bashrc.d/topics/brew.sh
identical .bashrc.d/topics/colors.sh
identical .bashrc.d/topics/deploy.sh
identical .bashrc.d/topics/git.sh
identical .bashrc.d/topics/go.sh
identical .bashrc.d/topics/homeshick.sh
identical .bashrc.d/topics/node.sh
identical .bashrc.d/topics/prompt.sh
identical .bashrc.d/topics/ruby.sh
identical .bashrc.d/topics/ssh.sh
...
Does it make sense to change the separator between action and the file? Maybe we could use a comma or a tab instead of a space so you can cut
with that delimiter and still be ok if your filenames have spaces, etc.
Agreed to everything. I'd go for the tab. Or instead maybe just remove the spaces in the left column?
I am not sure how removing spaces in the left column would work. How would the program interpreting the output know where to put them back so they could do something useful with the filename?
You'd just separate by the first space, so up to date
becomes uptodate
. Then you can use cut -d' ' -f2-
to get the filename and cut -d' ' -f1
to get the action. Then again, <tab>
is the standard for cut
, so it might really just be easier to use that.
Oh of course! I thought by 'left" column you meant the "right" column with the file name :disappointed:. All things considered, I agree using <tab>
is probably the best solution.
Currently homeshick outputs text that is very readable by a human when viewed through a terminal. However, when read by or though anything else it becomes quite a challenge because carriage returns (
\r
) and coloring have to be taken into account.homeshick should check whether STDOUT is the terminal and only then output data optimized for human viewing. This can easily be checked with
[ -t 1]
. This enhancement also makes unittests easier and allows for homeshick to be integrated with other code.