diff options
author | Alan Pearce | 2018-06-07 13:55:17 +0200 |
---|---|---|
committer | Alan Pearce | 2018-06-07 13:55:17 +0200 |
commit | 10dded485e1c2627575b2b9e21dfaabc31ee07f3 (patch) | |
tree | b3f0369bae776cd556078225fc446c10165f8624 /content/post/repository-management-with-ghq.md | |
parent | 956bf3a40be61da586bd5178a3868ca037eebbe8 (diff) | |
download | website-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.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 | |||
8 | projects automatically. Give it a repository URL, it will clone a project to | 8 | projects automatically. Give it a repository URL, it will clone a project to |
9 | your projects dir (set by `$GHQ_ROOT`) like so: | 9 | your 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 | ||
16 | I don't like the idea of having projects hidden away, so I set | 16 | I 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 | |||
23 | using [fzf][] as a fuzzy-finder, I thought it would be nice to use it | 23 | using [fzf][] as a fuzzy-finder, I thought it would be nice to use it |
24 | for this. I created a simple function, `fp` (find project) to do that: | 24 | for this. I created a simple function, `fp` (find project) to do that: |
25 | 25 | ||
26 | {{< highlight sh >}} | 26 | ```sh |
27 | fp () { | 27 | fp () { |
28 | ghq look $(ghq list | fzf +m) | 28 | ghq look $(ghq list | fzf +m) |
29 | } | 29 | } |
30 | {{< /highlight >}} | 30 | ``` |
31 | 31 | ||
32 | I ran into some issues with the subshell of `ghq look` and wondered | 32 | I ran into some issues with the subshell of `ghq look` and wondered |
33 | whether it might be possible to create a zsh command to remove the | 33 | whether it might be possible to create a zsh command to remove the |
@@ -36,7 +36,7 @@ need for a subshell. | |||
36 | I found that `fzf` includes a [cd-widget function][fzf-cd-widget] and created | 36 | I found that `fzf` includes a [cd-widget function][fzf-cd-widget] and created |
37 | something similar that uses `ghq` instead of `find`: | 37 | something similar that uses `ghq` instead of `find`: |
38 | 38 | ||
39 | {{< highlight sh >}} | 39 | ```sh |
40 | cd-project-widget () { | 40 | cd-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 | } |
54 | zle -N cd-project-widget | 54 | zle -N cd-project-widget |
55 | {{< /highlight >}} | 55 | ``` |
56 | 56 | ||
57 | It should be quite simple to modify it to work with other | 57 | It should be quite simple to modify it to work with other |
58 | fuzzy-finders. The basic idea is to show the output of `ghq list` for | 58 | 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`. | |||
62 | What's really nice about this, is that I can bind it to a key | 62 | What's really nice about this, is that I can bind it to a key |
63 | sequence: | 63 | sequence: |
64 | 64 | ||
65 | {{< highlight sh >}} | 65 | ```sh |
66 | bindkey '\es' cd-project-widget | 66 | bindkey '\es' cd-project-widget |
67 | {{< /highlight >}} | 67 | ``` |
68 | 68 | ||
69 | Now I can press `M-s` in a shell, start typing "dotfiles" and press enter to `cd` | 69 | Now I can press `M-s` in a shell, start typing "dotfiles" and press enter to `cd` |
70 | to my [dotfiles][] project. Pretty neat! | 70 | to my [dotfiles][] project. Pretty neat! |