diff options
Diffstat (limited to 'content/post/repository-management-with-ghq.md')
-rw-r--r-- | content/post/repository-management-with-ghq.md | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/content/post/repository-management-with-ghq.md b/content/post/repository-management-with-ghq.md index 6006605..d831c9e 100644 --- a/content/post/repository-management-with-ghq.md +++ b/content/post/repository-management-with-ghq.md @@ -8,10 +8,10 @@ I recently encountered [ghq][], a tool for automatically organising VCS-backed projects automatically. Give it a repository URL, it will clone a project to your projects dir (set by `$GHQ_ROOT`) like so: -{{< highlight sh >}} +```sh $ ghq get https://github.com/motemen/ghq # Runs `git clone https://github.com/motemen/ghq ~/.ghq/github.com/motemen/ghq` -{{< /highlight >}} +``` I don't like the idea of having projects hidden away, so I set `$GHQ_ROOT` to `$HOME/projects`. @@ -23,11 +23,11 @@ I wanted a nicer way to visit project directories. Since I'm using [fzf][] as a fuzzy-finder, I thought it would be nice to use it for this. I created a simple function, `fp` (find project) to do that: -{{< highlight sh >}} +```sh fp () { ghq look $(ghq list | fzf +m) } -{{< /highlight >}} +``` I ran into some issues with the subshell of `ghq look` and wondered whether it might be possible to create a zsh command to remove the @@ -36,7 +36,7 @@ need for a subshell. I found that `fzf` includes a [cd-widget function][fzf-cd-widget] and created something similar that uses `ghq` instead of `find`: -{{< highlight sh >}} +```sh cd-project-widget () { local cmd="ghq list" setopt localoptions pipefail 2> /dev/null @@ -52,7 +52,7 @@ cd-project-widget () { return $ret } zle -N cd-project-widget -{{< /highlight >}} +``` It should be quite simple to modify it to work with other fuzzy-finders. The basic idea is to show the output of `ghq list` for @@ -62,9 +62,9 @@ to print the correct directory for `cd`. What's really nice about this, is that I can bind it to a key sequence: -{{< highlight sh >}} +```sh bindkey '\es' cd-project-widget -{{< /highlight >}} +``` Now I can press `M-s` in a shell, start typing "dotfiles" and press enter to `cd` to my [dotfiles][] project. Pretty neat! |