├── .github └── workflows │ ├── build-binaries.yml │ └── tests.yml ├── .gitignore ├── CHANGELOG.md ├── Cargo.lock ├── Cargo.toml ├── LICENSE.txt ├── README.md ├── assets └── banner.svg ├── init ├── kn.bash ├── kn.fish └── kn.zsh ├── rustfmt.toml └── src ├── abbr.rs ├── args.rs ├── error.rs ├── init.rs ├── main.rs ├── query.rs └── utils.rs /.github/workflows/build-binaries.yml: -------------------------------------------------------------------------------- 1 | # Repurposed from `https://github.com/alexpdp7/cmdocker/blob/master/.github/workflows/quickstart.yml#L73`. 2 | 3 | name: Build binaries 4 | 5 | on: 6 | push: 7 | branches: [release] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | build-binary-linux-gnu: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v2 17 | - uses: actions-rs/toolchain@v1 18 | with: 19 | profile: minimal 20 | toolchain: nightly 21 | override: true 22 | target: x86_64-unknown-linux-gnu 23 | - run: mkdir bin 24 | - uses: actions-rs/cargo@v1 25 | with: 26 | command: build 27 | args: --release --target x86_64-unknown-linux-gnu -Z unstable-options --out-dir bin 28 | - name: Upload binary 29 | uses: actions/upload-artifact@v1 30 | with: 31 | name: kn-x86_64-unknown-linux-gnu 32 | path: bin/_kn 33 | 34 | build-binary-linux-musl: 35 | runs-on: ubuntu-latest 36 | steps: 37 | - uses: actions/checkout@v2 38 | - uses: actions-rs/toolchain@v1 39 | with: 40 | profile: minimal 41 | toolchain: nightly 42 | override: true 43 | target: x86_64-unknown-linux-musl 44 | - run: mkdir bin 45 | - uses: actions-rs/cargo@v1 46 | with: 47 | command: build 48 | args: --release --target x86_64-unknown-linux-musl -Z unstable-options --out-dir bin 49 | - name: Upload binary 50 | uses: actions/upload-artifact@v1 51 | with: 52 | name: kn-x86_64-unknown-linux-musl 53 | path: bin/_kn 54 | 55 | build-binary-macos: 56 | runs-on: macos-latest 57 | 58 | steps: 59 | - uses: actions/checkout@v2 60 | - uses: actions-rs/toolchain@v1 61 | with: 62 | profile: minimal 63 | toolchain: nightly 64 | override: true 65 | target: x86_64-apple-darwin 66 | - run: mkdir bin 67 | - uses: actions-rs/cargo@v1 68 | with: 69 | command: build 70 | args: --release --target x86_64-apple-darwin -Z unstable-options --out-dir bin 71 | - name: Upload binary 72 | uses: actions/upload-artifact@v1 73 | with: 74 | name: kn-x86_64-apple-darwin 75 | path: bin/_kn 76 | 77 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | pull_request: 7 | branches: [master] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | test: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v2 17 | - uses: actions-rs/toolchain@v1 18 | with: 19 | profile: minimal 20 | toolchain: stable 21 | override: true 22 | - uses: actions-rs/cargo@v1 23 | with: 24 | command: test 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | notepad.md 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | The format is inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). 4 | 5 | ## `0.3.3` - 2022-12-29 6 | 7 | - Update `powierża-coefficient` to `1.0.2`. 8 | 9 | ## `0.3.2` - 2022-07-17 (yanked) 10 | 11 | - Fix `--exclude-old-pwd` in `fish`. 12 | - Update `powierża-coefficient` to `1.0.1`. 13 | 14 | ## `0.3.1` - 2021-10-16 15 | 16 | - Fix shell scripts so that they don't exit the shell when no args were provided. 17 | 18 | ## `0.3.0` - 2021-10-14 (yanked) 19 | 20 | - Check if arg is a valid path before attempting abbreviation expansion. 21 | - Simplify `Congruence`. 22 | - Compare abbreviations and strings using [Powierża coefficient](https://github.com/micouy/powierza-coefficient) instead of Levenshtein distance. 23 | - Add `--exclude-old-pwd` flag to `_kn init`. 24 | - Remove interactive mode. 25 | - Add extensive docs. 26 | 27 | ## `0.2.2` - 2021-05-21 28 | 29 | ### Add 30 | 31 | - Handle components with more than 2 dots (`...` etc.) in the prefix in normal mode. 32 | 33 | ### Change 34 | 35 | - Remove state synchronization between search and UI. 36 | - Replace `clap` with `pico-args`. 37 | 38 | ### Remove 39 | 40 | - Remove `regex` and `ansi_term` from deps. 41 | 42 | ## `0.2.1` - 2021-05-16 43 | 44 | ### Fix 45 | 46 | - Fix shell scripts so that they remove the tmpfile. 47 | 48 | ## `0.2.0` - 2021-05-10 (yanked) 49 | 50 | ### Add 51 | 52 | - Add changelog. 53 | - Add interactive mode. 54 | - Add navigation with Tab and Shift + Tab or Ctrl + hjkl . 55 | - Add demos in [`README.md`](README.md). 56 | 57 | ### Change 58 | 59 | - Change shell scripts so that calling `kn` without args will enter interactive mode instead of changing current dir to `~`. 60 | - Move search to its own module. 61 | 62 | ## `0.1.0` - 2021-04-12 63 | 64 | ### Add 65 | 66 | - Add normal mode. 67 | - Handle abbreviations. 68 | - Handle prefix (`/`, `~`, `.`, etc.). 69 | - Handle wildcards (`-`). 70 | - Add shell scripts for `bash`, `fish` and `zsh`. 71 | - Add [`LICENSE.txt`](LICENSE.txt). 72 | - Add GitHub workflows. 73 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "alphanumeric-sort" 7 | version = "1.4.3" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "20e59b2ccb4c1ffbbf45af6f493e16ac65a66981c85664f1587816c0b08cd698" 10 | 11 | [[package]] 12 | name = "ansi_term" 13 | version = "0.12.1" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" 16 | dependencies = [ 17 | "winapi", 18 | ] 19 | 20 | [[package]] 21 | name = "bitflags" 22 | version = "1.3.2" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 25 | 26 | [[package]] 27 | name = "cfg-if" 28 | version = "1.0.0" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 31 | 32 | [[package]] 33 | name = "ctor" 34 | version = "0.1.21" 35 | source = "registry+https://github.com/rust-lang/crates.io-index" 36 | checksum = "ccc0a48a9b826acdf4028595adc9db92caea352f7af011a3034acd172a52a0aa" 37 | dependencies = [ 38 | "quote", 39 | "syn", 40 | ] 41 | 42 | [[package]] 43 | name = "diff" 44 | version = "0.1.12" 45 | source = "registry+https://github.com/rust-lang/crates.io-index" 46 | checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" 47 | 48 | [[package]] 49 | name = "dirs" 50 | version = "4.0.0" 51 | source = "registry+https://github.com/rust-lang/crates.io-index" 52 | checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" 53 | dependencies = [ 54 | "dirs-sys", 55 | ] 56 | 57 | [[package]] 58 | name = "dirs-sys" 59 | version = "0.3.6" 60 | source = "registry+https://github.com/rust-lang/crates.io-index" 61 | checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" 62 | dependencies = [ 63 | "libc", 64 | "redox_users", 65 | "winapi", 66 | ] 67 | 68 | [[package]] 69 | name = "getrandom" 70 | version = "0.2.3" 71 | source = "registry+https://github.com/rust-lang/crates.io-index" 72 | checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" 73 | dependencies = [ 74 | "cfg-if", 75 | "libc", 76 | "wasi", 77 | ] 78 | 79 | [[package]] 80 | name = "kn" 81 | version = "0.3.3" 82 | dependencies = [ 83 | "alphanumeric-sort", 84 | "dirs", 85 | "pico-args", 86 | "powierza-coefficient", 87 | "pretty_assertions", 88 | "serde", 89 | "serde_derive", 90 | "thiserror", 91 | "toml", 92 | ] 93 | 94 | [[package]] 95 | name = "libc" 96 | version = "0.2.112" 97 | source = "registry+https://github.com/rust-lang/crates.io-index" 98 | checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" 99 | 100 | [[package]] 101 | name = "output_vt100" 102 | version = "0.1.2" 103 | source = "registry+https://github.com/rust-lang/crates.io-index" 104 | checksum = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9" 105 | dependencies = [ 106 | "winapi", 107 | ] 108 | 109 | [[package]] 110 | name = "pico-args" 111 | version = "0.4.2" 112 | source = "registry+https://github.com/rust-lang/crates.io-index" 113 | checksum = "db8bcd96cb740d03149cbad5518db9fd87126a10ab519c011893b1754134c468" 114 | 115 | [[package]] 116 | name = "powierza-coefficient" 117 | version = "1.0.2" 118 | source = "registry+https://github.com/rust-lang/crates.io-index" 119 | checksum = "04123079750026568dff0e68efe1ca676f6686023f3bf7686b87dab661c0375b" 120 | 121 | [[package]] 122 | name = "pretty_assertions" 123 | version = "0.7.2" 124 | source = "registry+https://github.com/rust-lang/crates.io-index" 125 | checksum = "1cab0e7c02cf376875e9335e0ba1da535775beb5450d21e1dffca068818ed98b" 126 | dependencies = [ 127 | "ansi_term", 128 | "ctor", 129 | "diff", 130 | "output_vt100", 131 | ] 132 | 133 | [[package]] 134 | name = "proc-macro2" 135 | version = "1.0.30" 136 | source = "registry+https://github.com/rust-lang/crates.io-index" 137 | checksum = "edc3358ebc67bc8b7fa0c007f945b0b18226f78437d61bec735a9eb96b61ee70" 138 | dependencies = [ 139 | "unicode-xid", 140 | ] 141 | 142 | [[package]] 143 | name = "quote" 144 | version = "1.0.10" 145 | source = "registry+https://github.com/rust-lang/crates.io-index" 146 | checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" 147 | dependencies = [ 148 | "proc-macro2", 149 | ] 150 | 151 | [[package]] 152 | name = "redox_syscall" 153 | version = "0.2.10" 154 | source = "registry+https://github.com/rust-lang/crates.io-index" 155 | checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" 156 | dependencies = [ 157 | "bitflags", 158 | ] 159 | 160 | [[package]] 161 | name = "redox_users" 162 | version = "0.4.0" 163 | source = "registry+https://github.com/rust-lang/crates.io-index" 164 | checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" 165 | dependencies = [ 166 | "getrandom", 167 | "redox_syscall", 168 | ] 169 | 170 | [[package]] 171 | name = "serde" 172 | version = "1.0.131" 173 | source = "registry+https://github.com/rust-lang/crates.io-index" 174 | checksum = "b4ad69dfbd3e45369132cc64e6748c2d65cdfb001a2b1c232d128b4ad60561c1" 175 | 176 | [[package]] 177 | name = "serde_derive" 178 | version = "1.0.131" 179 | source = "registry+https://github.com/rust-lang/crates.io-index" 180 | checksum = "b710a83c4e0dff6a3d511946b95274ad9ca9e5d3ae497b63fda866ac955358d2" 181 | dependencies = [ 182 | "proc-macro2", 183 | "quote", 184 | "syn", 185 | ] 186 | 187 | [[package]] 188 | name = "syn" 189 | version = "1.0.80" 190 | source = "registry+https://github.com/rust-lang/crates.io-index" 191 | checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194" 192 | dependencies = [ 193 | "proc-macro2", 194 | "quote", 195 | "unicode-xid", 196 | ] 197 | 198 | [[package]] 199 | name = "thiserror" 200 | version = "1.0.30" 201 | source = "registry+https://github.com/rust-lang/crates.io-index" 202 | checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" 203 | dependencies = [ 204 | "thiserror-impl", 205 | ] 206 | 207 | [[package]] 208 | name = "thiserror-impl" 209 | version = "1.0.30" 210 | source = "registry+https://github.com/rust-lang/crates.io-index" 211 | checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" 212 | dependencies = [ 213 | "proc-macro2", 214 | "quote", 215 | "syn", 216 | ] 217 | 218 | [[package]] 219 | name = "toml" 220 | version = "0.5.8" 221 | source = "registry+https://github.com/rust-lang/crates.io-index" 222 | checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" 223 | dependencies = [ 224 | "serde", 225 | ] 226 | 227 | [[package]] 228 | name = "unicode-xid" 229 | version = "0.2.2" 230 | source = "registry+https://github.com/rust-lang/crates.io-index" 231 | checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" 232 | 233 | [[package]] 234 | name = "wasi" 235 | version = "0.10.2+wasi-snapshot-preview1" 236 | source = "registry+https://github.com/rust-lang/crates.io-index" 237 | checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" 238 | 239 | [[package]] 240 | name = "winapi" 241 | version = "0.3.9" 242 | source = "registry+https://github.com/rust-lang/crates.io-index" 243 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 244 | dependencies = [ 245 | "winapi-i686-pc-windows-gnu", 246 | "winapi-x86_64-pc-windows-gnu", 247 | ] 248 | 249 | [[package]] 250 | name = "winapi-i686-pc-windows-gnu" 251 | version = "0.4.0" 252 | source = "registry+https://github.com/rust-lang/crates.io-index" 253 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 254 | 255 | [[package]] 256 | name = "winapi-x86_64-pc-windows-gnu" 257 | version = "0.4.0" 258 | source = "registry+https://github.com/rust-lang/crates.io-index" 259 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 260 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "kn" 3 | version = "0.3.3" 4 | edition = "2018" 5 | autobins = false 6 | include = [ 7 | "**/*.rs", 8 | "init", 9 | "Cargo.toml", 10 | "Cargo.lock", 11 | "README.md", 12 | "LICENSE.txt", 13 | "CHANGELOG.md", 14 | "rustfmt.toml", 15 | ] 16 | 17 | authors = ["micouy"] 18 | description = "nvgt/fldrs/qckly" 19 | repository = "https://github.com/micouy/kn" 20 | readme = "README.md" 21 | license = "MIT" 22 | 23 | categories = ["command-line-utilities", "filesystem"] 24 | keywords = ["cli", "utility", "filesystem"] 25 | 26 | [[bin]] 27 | name = "_kn" 28 | path = "src/main.rs" 29 | 30 | [dependencies] 31 | alphanumeric-sort = "1.4" 32 | thiserror = "1.0" 33 | pico-args = { version = "0.4", features = [] } 34 | powierza-coefficient = "1.0.2" 35 | serde_derive = "1.0" 36 | serde = "1.0" 37 | toml = "0.5" 38 | dirs = "4.0" 39 | 40 | [dev-dependencies] 41 | pretty_assertions = "0.7" 42 | 43 | [profile.release] 44 | lto = true 45 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Mikołaj Powierża 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # `kn` — nvgt/fldrs/qckly 2 | 3 |  4 | [](https://crates.io/crates/kn) 5 | 6 |
7 |
8 |
(arg: &P, excluded: Option (arg: &P) -> Result<(Option (path: &P) -> &Path
45 | where
46 | P: AsRef