Skip to content

Commit

Permalink
Add support for Alfred (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
denisidoro authored Apr 19, 2020
1 parent 019adf8 commit c7f919e
Show file tree
Hide file tree
Showing 19 changed files with 850 additions and 54 deletions.
23 changes: 21 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,27 @@ on:
- '*'

jobs:
publish:
name: Publish for ${{ matrix.os }}

alfred:
name: Publish Alfred workflow
os: macos-latest
steps:
- uses: actions/checkout@v1
- name: Zip
run: scripts/action workflow
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Upload workflow to release
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/workflow/navi.zip
tag: ${{ github.ref }}
asset_name: navi-${{ steps.get_version.outputs.VERSION }}.alfredworkflow

binary:
name: Publish binary for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "navi"
version = "2.5.2"
version = "2.6.0"
authors = ["Denis Isidoro <[email protected]>"]
edition = "2018"
description = "An interactive cheatsheet tool for the command-line"
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

> :information_source: If you're here because you upgraded **navi** and are having some issues, please check [this thread](https://github.com/denisidoro/navi/issues/201).
An interactive cheatsheet tool for the command-line.
An interactive cheatsheet tool for the command-line and application launchers.

![Demo](https://user-images.githubusercontent.com/3226564/76437136-ddc35900-6397-11ea-823c-d2da7615fe60.gif)
![Terminal demo](https://user-images.githubusercontent.com/3226564/76437136-ddc35900-6397-11ea-823c-d2da7615fe60.gif)

**navi** allows you to browse through cheatsheets (that you may write yourself or download from maintainers) and execute commands. Argument suggestions are prompted to you.

Expand All @@ -13,7 +13,9 @@ An interactive cheatsheet tool for the command-line.
- it will spare you from knowing CLIs by heart;
- it will teach you new one-liners.

It uses [fzf](https://github.com/junegunn/fzf) or [skim](https://github.com/lotabout/skim) under the hood and it can be either used as a command or as a shell widget (*à la* Ctrl-R).
It uses [fzf](https://github.com/junegunn/fzf), [skim](https://github.com/lotabout/skim), or [Alfred](https://www.alfredapp.com/) under the hood and it can be either used as a command or as a shell widget (*à la* Ctrl-R).

![Alfred demo](https://user-images.githubusercontent.com/3226564/79696281-35d06380-8252-11ea-87d5-dc619d869e81.gif)

Table of contents
-----------------
Expand All @@ -27,6 +29,7 @@ Table of contents
* [Other package managers](#other-package-managers)
* [Usage](#usage)
* [Shell widget](#shell-widget)
* [Alfred](#alfred)
* [More options](#more-options)
* [Trying out online](#trying-out-online)
* [Cheatsheets](#cheatsheets)
Expand Down Expand Up @@ -112,6 +115,8 @@ navi widget fish | source

By default, `Ctrl+G` is assigned to launching **navi**.

### Alfred

### More options

Please refer to `navi --help` for more details.
Expand Down Expand Up @@ -248,7 +253,7 @@ $ jsons: find . -iname '*.json' -type f -print --- --multi
List customization
------------------

Lists can be stylized with the [$FZF_DEFAULT_OPTS](https://github.com/junegunn/fzf#layout) environment variable or similar variables or parameters ( please refer to `navi --help`). This way, you can change the [color scheme](https://github.com/junegunn/fzf/wiki/Color-schemes), for example.
Lists can be stylized with the [$FZF_DEFAULT_OPTS](https://github.com/junegunn/fzf#layout) environment variable or similar variables/parameters (please refer to `navi --help`). This way, you can change the [color scheme](https://github.com/junegunn/fzf/wiki/Color-schemes), for example.


Related projects
Expand Down
9 changes: 9 additions & 0 deletions alfred/alfred.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

source "${HOME}/.bashrc"

if [ -n "${snippet:-}" ]; then
navi alfred suggestions
else
navi alfred start
fi
15 changes: 15 additions & 0 deletions alfred/alfred2.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

_interpolate() {
local -r snippet="$1"
local -r varname="$2"
local -r value="${!varname}"

echo "$snippet" | sed "s/<${varname}>/${value}/g"
}

if [ -n "${varname:-}" ]; then
echo -n "$(_interpolate "$snippet" "$varname" || echo "")"
else
echo -n "$snippet"
fi
Loading

0 comments on commit c7f919e

Please sign in to comment.