Skip to content
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

Add list command #50

Merged
merged 3 commits into from
May 29, 2016
Merged

Add list command #50

merged 3 commits into from
May 29, 2016

Conversation

arrrggghhh
Copy link
Contributor

Hi,

I added a bash command to list git repositories in certain directories.

It doesn't start with git, but I found it useful in my workflow. I thought it might help some people.

Thanks!

Update find command to exclude hidden directories.
Add GNU find command
@arrrggghhh
Copy link
Contributor Author

I'm not sure why, commands get wrapped.

@hemanth
Copy link
Contributor

hemanth commented May 29, 2016

Looks fine now?

@hemanth hemanth merged commit b107c64 into git-tips:master May 29, 2016
@arrrggghhh
Copy link
Contributor Author

arrrggghhh commented May 30, 2016

@hemanth

It seems dollar signs in the last commands act like they are new line characters.

I tried to escape them with backslash, but pre commit hook says Unexpected token $ in JSON.

Currently, merged commands are broken and won't work.

This is what I inserted at the end of tips.json:

{
  "title": "List of git repositories in multiple directories.",
  "tip": "find -E /path1 /path2 /path3 \\( -regex '.*/\\.git$' -not -regex '.*/\\..*/\\.git$' \\) -type d -print0 | xargs -0 -I {} dirname {}",
  "alternatives": [
    "find /path1 /path2 /path3 -regextype posix-egrep \\( -regex '.*/\\.git$' -not -regex '.*/\\..*/\\.git$' \\) -type d -print0 | xargs -0 -I {} dirname {}"
  ]
}

And this is the generated markdown:

## List of git repositories in multiple directories.
```sh
find -E /path1 /path2 /path3 \( -regex '.*/\.git
 -not -regex '.*/\..*/\.git
 \) -type d -print0 | xargs -0 -I {} dirname {}
```
__Alternatives:__
```sh
find /path1 /path2 /path3 -regextype posix-egrep \( -regex '.*/\.git
 -not -regex '.*/\..*/\.git
 \) -type d -print0 | xargs -0 -I {} dirname {}
```

Also, this is the commands what I actually intended and confirmed to work:

# tip
find -E /path1 /path2 /path3 \( -regex '.*/\.git$' -not -regex '.*/\..*/\.git$' \) -type d -print0 | xargs -0 -I {} dirname {}

# alternatives
find /path1 /path2 /path3 -regextype posix-egrep \( -regex '.*/\.git$' -not -regex '.*/\..*/\.git$' \) -type d -print0 | xargs -0 -I {} dirname {}

Please take a look at this. Thanks!

@hemanth
Copy link
Contributor

hemanth commented May 30, 2016

I am in a transit now.

//cc @spacewander got some spare time? 😇

@spacewander
Copy link

Maybe a bug of doxie?

@hemanth
Copy link
Contributor

hemanth commented May 31, 2016

@spacewander Right, my bad...he was referring to the formatting issue, I was thinking it was something to do with the find command.

//cc @tomekwi

@spacewander
Copy link

@hemanth
Well...Don't mind it! As for the find command, we can shorten it from:

-regextype posix-egrep \( -regex '.*/\.git$' -not -regex '.*/\..*/\.git$' \) -type d -print0 | xargs -0 -I {} dirname {}

to

-regextype posix-egrep \( -regex '[^/]*/([^.]*/)*\.git$' \) -type d -exec dirname {} \;

Use -exec to replace xargs, and squash two regexes into one.

blanjatest2 pushed a commit to blanjatest2/tips that referenced this pull request Apr 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants