-
Notifications
You must be signed in to change notification settings - Fork 4
Examples
Michał Nowotnik edited this page Jun 20, 2022
·
9 revisions
Here you will find usage examples.
Feel free to make a PR and add your own! Don't forget to attribute it to yourself.
- pattern: 'git commit -m "'
selectOne: true
cmd: git rev-parse --abbrev-ref HEAD
map: '{{ .item | split "/" | mapGet "_1" }}'
Before:
~/Projects/fzshell feature/FZ-123
❯ git commit -m "
After:
~/Projects/fzshell feature/FZ-123
❯ git commit -m "FZ-123
Expands pusho
into push origin
command that uses current branch as a origin.
- pattern: 'git pusho'
selectOne: true
cmd: "git rev-parse --abbrev-ref HEAD"
map: ' push -u origin {{.item}}'
replacement: "git {{.item}}"
Before:
~/Projects/fzshell feature/FZ-123
❯ git pusho
After:
~/Projects/fzshell feature/FZ-123
❯ git push -u origin feature/FZ-123
- pattern: '(git rebase *-?i?) *'
replacement: '{{._1}} {{.item | splitList " " | listGet 0}}'
cmd: git log --oneline
preview: >
git show --color '{{.item | splitList " " | listGet 0 }}'
- pattern: "docker rm"
cmd: "docker ps -a --format '{{.Names}}\t{{.ID}}\t{{.Image}}\t{{.Status}}'"
map: ' {{ .item | split "\t" | mapGet "_0" }}'
- pattern: "docker rmi"
cmd: "docker images --format '{{.Repository}}:{{.Tag}}\t{{.ID}}'"
map: ' {{ .item | splitList "\t" | last }}'
preview: '{{ shell "docker image inspect " .item }}'
- pattern: 'kubectl (.+) (pod/)'
cmd: "kubectl get pods"
map: '{{ .item | split " " | mapGet "_0" }}'
headerLines: 1
- pattern: "jq '?(\\.[^']*)'? (\\w+.json)"
replacement: jq '{{._1}}[{{ .item }}]' {{._2}}
cmd: 'jq $1 $2 | jq keys | jq ". []"'
preview: jq -C '{{._1}}[{{.item}}]' {{._2}}
Matching pattern example: jq . pets.json
Alternative pattern:
- pattern: 'cat (\w+\.json) \| jq (\..*)'
cmd: 'jq $2 $1 | jq keys | jq ". []"'
map: '{{ ternary (printf ".%s" .item) (printf "[%s]" .item) (hasPrefix "\"" .item) }}'
preview: jq -C '{{._2}}[{{.item}}]' {{._1}}
Matching pattern example: cat pets.json | jq .
- pattern: "mvn .+ -Dtest="
cmd: find . -name '*.java'
map: '{{$v := .item | splitList "/" | last }}{{ regexReplaceAll "\\.\\w+$" $v "" }}'