mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-08-23 22:16:48 +00:00
Add zoxide
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
---
|
||||
title: zoxide
|
||||
homepage: https://github.com/ajeetdsouza/zoxide
|
||||
tagline: |
|
||||
zoxide: A smarter cd command.
|
||||
---
|
||||
|
||||
## Cheat Sheet
|
||||
|
||||
`zoxide` is a smarter `cd` command for your terminal. It keeps track of the
|
||||
directories you visit, so that you can switch to them using just a few
|
||||
keystrokes.
|
||||
|
||||

|
||||
|
||||
## Usage
|
||||
|
||||
```sh
|
||||
z foo # cd to highest ranked directory matching foo
|
||||
z foo bar # cd to highest ranked directory matching foo and bar
|
||||
|
||||
z foo/ # can also cd into actual directories
|
||||
z .. # cd into parent directory
|
||||
z - # cd into previous directory
|
||||
|
||||
zi foo # cd with interactive selection (requires fzf)
|
||||
```
|
||||
|
||||
## Add zoxide to your shell
|
||||
|
||||
To use zoxide, it needs to be first initialized on your shell:
|
||||
|
||||
### bash
|
||||
|
||||
Add the following line to your configuration file (usually `~/.bashrc`):
|
||||
|
||||
```sh
|
||||
eval "$(zoxide init bash)"
|
||||
```
|
||||
|
||||
### elvish
|
||||
|
||||
Add the following line to your configuration file (usually `~/.elvish/rc.elv`):
|
||||
|
||||
```sh
|
||||
eval $(zoxide init elvish | slurp)
|
||||
```
|
||||
|
||||
### fish
|
||||
|
||||
Add the following line to your configuration file (usually `~/.config/fish/config.fish`):
|
||||
|
||||
```fish
|
||||
zoxide init fish | source
|
||||
```
|
||||
|
||||
### nushell
|
||||
|
||||
Initialize zoxide's Nushell script:
|
||||
|
||||
```sh
|
||||
zoxide init nushell --hook prompt | save ~/.zoxide.nu
|
||||
```
|
||||
|
||||
Then, in your Nushell configuration file:
|
||||
|
||||
- Prepend `__zoxide_hook;` to the `prompt` variable.
|
||||
- Add the following lines to the `startup` variable:
|
||||
- `zoxide init nushell --hook prompt | save ~/.zoxide.nu`
|
||||
- `source ~/.zoxide.nu`
|
||||
|
||||
### powershell
|
||||
|
||||
Add the following line to your profile:
|
||||
|
||||
```powershell
|
||||
Invoke-Expression (& {
|
||||
$hook = if ($PSVersionTable.PSVersion.Major -lt 6) { 'prompt' } else { 'pwd' }
|
||||
(zoxide init --hook $hook powershell) -join "`n"
|
||||
})
|
||||
```
|
||||
|
||||
### xonsh
|
||||
|
||||
Add the following line to your configuration file (usually `~/.xonshrc`):
|
||||
|
||||
```python
|
||||
execx($(zoxide init xonsh), 'exec', __xonsh__.ctx, filename='zoxide')
|
||||
```
|
||||
|
||||
### zsh
|
||||
|
||||
Add the following line to your configuration file (usually `~/.zshrc`):
|
||||
|
||||
```sh
|
||||
eval "$(zoxide init zsh)"
|
||||
```
|
||||
|
||||
### Any POSIX shell
|
||||
|
||||
Add the following line to your configuration file:
|
||||
|
||||
```sh
|
||||
eval "$(zoxide init posix --hook prompt)"
|
||||
```
|
||||
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env pwsh
|
||||
|
||||
##################
|
||||
# Install zoxide #
|
||||
##################
|
||||
|
||||
# Every package should define these variables
|
||||
$pkg_cmd_name = "zoxide"
|
||||
|
||||
$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\zoxide.exe"
|
||||
$pkg_dst = "$pkg_dst_cmd"
|
||||
|
||||
$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\zoxide-v$Env:WEBI_VERSION\bin\zoxide.exe"
|
||||
$pkg_src_bin = "$Env:USERPROFILE\.local\opt\zoxide-v$Env:WEBI_VERSION\bin"
|
||||
$pkg_src_dir = "$Env:USERPROFILE\.local\opt\zoxide-v$Env:WEBI_VERSION"
|
||||
$pkg_src = "$pkg_src_cmd"
|
||||
|
||||
$pkg_download = "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"
|
||||
|
||||
# Fetch archive
|
||||
IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE")) {
|
||||
# TODO: arch detection
|
||||
Write-Output "Downloading zoxide from $Env:WEBI_PKG_URL to $pkg_download"
|
||||
& curl.exe -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part"
|
||||
& Move-Item "$pkg_download.part" "$pkg_download"
|
||||
}
|
||||
|
||||
IF (!(Test-Path -Path "$pkg_src_cmd")) {
|
||||
Write-Output "Installing zoxide"
|
||||
|
||||
# Enter tmp
|
||||
Push-Location ".local\tmp"
|
||||
|
||||
# Remove any leftover tmp cruft
|
||||
Remove-Item -Path ".\zoxide*" -Recurse -ErrorAction Ignore
|
||||
|
||||
# Unpack archive
|
||||
Write-Output "Unpacking $pkg_download"
|
||||
& tar xf "$pkg_download"
|
||||
|
||||
# Settle unpacked archive into place
|
||||
Write-Output "Install Location: $pkg_src_cmd"
|
||||
New-Item "$pkg_src_bin" -ItemType Directory -Force
|
||||
Move-Item -Path "zoxide.exe" -Destination "$pkg_src_bin"
|
||||
|
||||
# Exit tmp
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
Write-Output "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'"
|
||||
Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore
|
||||
Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
function __init_zoxide() {
|
||||
set -e
|
||||
set -u
|
||||
|
||||
##################
|
||||
# Install zoxide #
|
||||
##################
|
||||
|
||||
# Every package should define these 6 variables
|
||||
pkg_cmd_name="zoxide"
|
||||
|
||||
pkg_dst_cmd="$HOME/.local/bin/zoxide"
|
||||
pkg_dst="$pkg_dst_cmd"
|
||||
|
||||
pkg_src_cmd="$HOME/.local/opt/zoxide-v$WEBI_VERSION/bin/zoxide"
|
||||
pkg_src_dir="$HOME/.local/opt/zoxide-v$WEBI_VERSION"
|
||||
pkg_src="$pkg_src_cmd"
|
||||
|
||||
# pkg_install must be defined by every package
|
||||
pkg_install() {
|
||||
# mkdir -p "~/.local/opt/zoxide-v0.99.9/bin"
|
||||
mkdir -p "$(dirname "$pkg_src_cmd")"
|
||||
|
||||
# mv ./zoxide-*/zoxide "~/.local/opt/zoxide-v0.99.9/bin/zoxide"
|
||||
mv ./zoxide-*/zoxide "$pkg_src_cmd"
|
||||
}
|
||||
|
||||
# pkg_get_current_version is recommended, but (soon) not required
|
||||
pkg_get_current_version() {
|
||||
# 'zoxide --version' has output in this format:
|
||||
# zoxide v0.5.0-31-g8452961
|
||||
# This trims it down to just the version number:
|
||||
# 0.5.0
|
||||
zoxide --version 2>/dev/null | head -n 1 | cut -d '-' -f 1 | cut -b '9-'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
__init_zoxide
|
||||
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
var github = require('../_common/github.js');
|
||||
var owner = 'ajeetdsouza';
|
||||
var repo = 'zoxide';
|
||||
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the first 5 for demonstration
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user