andsens / homeshick

git dotfiles synchronizer written in bash
MIT License
2.11k stars 145 forks source link

adds support for git style external commands #39

Closed pdex closed 11 years ago

pdex commented 11 years ago

Git allows you to create custom commands by placing an executable with the name git-"command" in your path. This follows the same convention and will execute homeshick-"command" passing in any remaining parameters from the command line. If it can't find the command it will error out.

andsens commented 11 years ago

Help me out here: I fail to see the possible application for this?

pdex commented 11 years ago

I'm playing around with adding some commands to do something similar to pushd/popd but with a subshell. This may not be for everyone, so I figured doing it as an external command allows more flexibility.

andsens commented 11 years ago

Hold on, that may actually be quite interesting. I once thought of implementing homeshick cd until I remembered that it runs as a subshell and none of its state goes into the parent shell.
You're thinking of simply invoking $SHELL? @mlawren actually cooked something up that looks quite interesting and which may play into that. A pushd/popd feature may in fact obviate the need to implement #27 at all. I reopened #30 if you'd like to continue discussing it.

pdex commented 11 years ago

Here's the idea that I'm playing with right now:

$ cat ~/bin/homeshick-storm 
#!/bin/bash

CASTLE="$HOME/.homesick/repos/$1"
if [[ -n "$1" && -d "$CASTLE" ]]; then
  export PS1="(Castle:`basename \"$CASTLE\"`)\n$PS1"
  cd $CASTLE
  $SHELL
fi
exit 0
pdex commented 11 years ago

The scope of this has changed, do you want me to make a new pull request?

andsens commented 11 years ago

Yeah. maybe with a rebase so the ext_command is not even a commit? I like the "storm" metaphor, retreating into the castle :-) Though I think people may get tired of writing that instead of simply "cd"?