about summary refs log tree commit diff stats
path: root/content/post/repository-management-with-ghq.md
diff options
context:
space:
mode:
authorAlan Pearce2018-06-07 13:55:17 +0200
committerAlan Pearce2018-06-07 13:55:17 +0200
commit10dded485e1c2627575b2b9e21dfaabc31ee07f3 (patch)
treeb3f0369bae776cd556078225fc446c10165f8624 /content/post/repository-management-with-ghq.md
parent956bf3a40be61da586bd5178a3868ca037eebbe8 (diff)
downloadwebsite-10dded485e1c2627575b2b9e21dfaabc31ee07f3.tar.lz
website-10dded485e1c2627575b2b9e21dfaabc31ee07f3.tar.zst
website-10dded485e1c2627575b2b9e21dfaabc31ee07f3.zip
Use code fences instead of template tags for syntax highlighting
Diffstat (limited to 'content/post/repository-management-with-ghq.md')
-rw-r--r--content/post/repository-management-with-ghq.md16
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
8projects automatically. Give it a repository URL, it will clone a project to 8projects automatically. Give it a repository URL, it will clone a project to
9your projects dir (set by `$GHQ_ROOT`) like so: 9your projects dir (set by `$GHQ_ROOT`) like so:
10 10
11{{< highlight sh >}} 11```sh
12$ ghq get https://github.com/motemen/ghq 12$ ghq get https://github.com/motemen/ghq
13# Runs `git clone https://github.com/motemen/ghq ~/.ghq/github.com/motemen/ghq` 13# Runs `git clone https://github.com/motemen/ghq ~/.ghq/github.com/motemen/ghq`
14{{< /highlight >}} 14```
15 15
16I don't like the idea of having projects hidden away, so I set 16I don't like the idea of having projects hidden away, so I set
17`$GHQ_ROOT` to `$HOME/projects`. 17`$GHQ_ROOT` to `$HOME/projects`.
@@ -23,11 +23,11 @@ I wanted a nicer way to visit project directories. Since I'm
23using [fzf][] as a fuzzy-finder, I thought it would be nice to use it 23using [fzf][] as a fuzzy-finder, I thought it would be nice to use it
24for this. I created a simple function, `fp` (find project) to do that: 24for this. I created a simple function, `fp` (find project) to do that:
25 25
26{{< highlight sh >}} 26```sh
27fp () { 27fp () {
28 ghq look $(ghq list | fzf +m) 28 ghq look $(ghq list | fzf +m)
29} 29}
30{{< /highlight >}} 30```
31 31
32I ran into some issues with the subshell of `ghq look` and wondered 32I ran into some issues with the subshell of `ghq look` and wondered
33whether it might be possible to create a zsh command to remove the 33whether it might be possible to create a zsh command to remove the
@@ -36,7 +36,7 @@ need for a subshell.
36I found that `fzf` includes a [cd-widget function][fzf-cd-widget] and created 36I found that `fzf` includes a [cd-widget function][fzf-cd-widget] and created
37something similar that uses `ghq` instead of `find`: 37something similar that uses `ghq` instead of `find`:
38 38
39{{< highlight sh >}} 39```sh
40cd-project-widget () { 40cd-project-widget () {
41 local cmd="ghq list" 41 local cmd="ghq list"
42 setopt localoptions pipefail 2> /dev/null 42 setopt localoptions pipefail 2> /dev/null
@@ -52,7 +52,7 @@ cd-project-widget () {
52 return $ret 52 return $ret
53} 53}
54zle -N cd-project-widget 54zle -N cd-project-widget
55{{< /highlight >}} 55```
56 56
57It should be quite simple to modify it to work with other 57It should be quite simple to modify it to work with other
58fuzzy-finders. The basic idea is to show the output of `ghq list` for 58fuzzy-finders. The basic idea is to show the output of `ghq list` for
@@ -62,9 +62,9 @@ to print the correct directory for `cd`.
62What's really nice about this, is that I can bind it to a key 62What's really nice about this, is that I can bind it to a key
63sequence: 63sequence:
64 64
65{{< highlight sh >}} 65```sh
66bindkey '\es' cd-project-widget 66bindkey '\es' cd-project-widget
67{{< /highlight >}} 67```
68 68
69Now I can press `M-s` in a shell, start typing "dotfiles" and press enter to `cd` 69Now I can press `M-s` in a shell, start typing "dotfiles" and press enter to `cd`
70to my [dotfiles][] project. Pretty neat! 70to my [dotfiles][] project. Pretty neat!