add lsd
authorAJ ONeal <aj@therootcompany.com>
Sat, 22 Aug 2020 22:18:59 +0000 (22:18 +0000)
committerAJ ONeal <aj@therootcompany.com>
Sat, 22 Aug 2020 23:56:13 +0000 (23:56 +0000)
lsd/README.md [new file with mode: 0644]
lsd/install.ps1 [new file with mode: 0644]
lsd/install.sh [new file with mode: 0644]
lsd/releases.js [new file with mode: 0644]

diff --git a/lsd/README.md b/lsd/README.md
new file mode 100644 (file)
index 0000000..a48b08b
--- /dev/null
@@ -0,0 +1,83 @@
+---
+title: LSDeluxe
+homepage: https://github.com/Peltoche/lsd
+tagline: |
+  LSDeluxe: next gen ls command
+---
+
+### Updating `lsd`
+
+`webi lsd@stable`
+
+Use the `@beta` tag for pre-releases.
+
+## Cheat Sheet
+
+![](https://raw.githubusercontent.com/Peltoche/lsd/assets/screen_lsd.png)
+
+> `lsd` is a modern, cross-platform, drop-in replacement for `ls`. It does
+> everything that you expect it to, plus modern extras that you can check out
+> with `lsd --help`.
+
+Note: You must install [the nerdfont](https://webinstall.dev/nerdfont) and
+update the font in your Terminal for `lsd` to show icons.
+
+Run `lsd` exactly as you would `ls`:
+
+```bash
+lsd
+```
+
+But wait, there's more, you can `tree` as well:
+
+```bash
+lsd --tree
+```
+
+### How to turn off icons and colors
+
+If you just want the benefits of a cross-platform `ls` without having to install
+nerdfont or needing a modern terminal, you've got options:
+
+```bash
+lsd --icon=never --color=never
+```
+
+Since that can be a little awkward to type over and over, you can use an alias:
+
+```bash
+alias lsd=lsd --icon=never --color=never
+lsd
+```
+
+### How to alias as `ls`, `ll`, `la`, etc
+
+Update your `.bashrc`, `.zshrc`, or `.profile`
+
+```bash
+alias ls="lsd"
+alias la="lsd -A"
+alias ll="lsd -l"
+alias lg="lsd --group-dirs=first"
+```
+
+For situations in which you must use `ls` exactly, remember that you can escape
+the alias:
+
+```bash
+\ls
+```
+
+### How to alias as `tree`
+
+Update your `.bashrc`, `.zshrc`, or `.profile`
+
+```bash
+alias tree="lsd --tree"
+```
+
+And when you want to use GNU `tree`, just escape the alias:
+
+```bash
+\tree
+```
diff --git a/lsd/install.ps1 b/lsd/install.ps1
new file mode 100644 (file)
index 0000000..3722062
--- /dev/null
@@ -0,0 +1,58 @@
+#!/usr/bin/env pwsh
+
+###############
+# Install lsd #
+###############
+
+# Every package should define these variables
+$pkg_cmd_name = "lsd"
+
+$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\lsd.exe"
+$pkg_dst = "$pkg_dst_cmd"
+
+$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\lsd-v$Env:WEBI_VERSION\bin\lsd.exe"
+$pkg_src_bin = "$Env:USERPROFILE\.local\opt\lsd-v$Env:WEBI_VERSION\bin"
+$pkg_src_dir = "$Env:USERPROFILE\.local\opt\lsd-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
+    echo "Downloading lsd from $Env:WEBI_PKG_URL to $pkg_download"
+    & curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part"
+    & move "$pkg_download.part" "$pkg_download"
+}
+
+IF (!(Test-Path -Path "$pkg_src_cmd"))
+{
+    echo "Installing lsd"
+
+    # TODO: create package-specific temp directory
+    # Enter tmp
+    pushd .local\tmp
+
+        # Remove any leftover tmp cruft 
+        Remove-Item -Path ".\lsd-v*" -Recurse -ErrorAction Ignore
+        Remove-Item -Path ".\lsd.exe" -Recurse -ErrorAction Ignore
+
+        # Unpack archive file into this temporary directory
+        # Windows BSD-tar handles zip. Imagine that.
+        echo "Unpacking $pkg_download"
+        & tar xf "$pkg_download"
+        & dir
+
+        # Settle unpacked archive into place
+        echo "Install Location: $pkg_src_cmd"
+        New-Item "$pkg_src_bin" -ItemType Directory
+        Move-Item -Path ".\lsd-*\lsd.exe" -Destination "$pkg_src_bin"
+
+    # Exit tmp
+    popd
+}
+
+echo "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
diff --git a/lsd/install.sh b/lsd/install.sh
new file mode 100644 (file)
index 0000000..ac80315
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+{
+    set -e
+    set -u
+
+    ###############
+    # Install lsd #
+    ###############
+
+    # Every package should define these 6 variables
+    pkg_cmd_name="lsd"
+
+    pkg_dst_cmd="$HOME/.local/bin/lsd"
+    pkg_dst="$pkg_dst_cmd"
+
+    pkg_src_cmd="$HOME/.local/opt/lsd-v$WEBI_VERSION/bin/lsd"
+    pkg_src_dir="$HOME/.local/opt/lsd-v$WEBI_VERSION"
+    pkg_src="$pkg_src_cmd"
+
+    # pkg_install must be defined by every package
+    pkg_install() {
+        # ~/.local/opt/lsd-v0.17.0/bin
+        mkdir -p "$(dirname $pkg_src_cmd)"
+
+        # mv ./lsd-*/lsd ~/.local/opt/lsd-v0.17.0/bin/lsd
+        mv ./lsd-*/lsd "$pkg_src_cmd"
+    }
+
+    # pkg_get_current_version is recommended, but (soon) not required
+    pkg_get_current_version() {
+        # 'lsd --version' has output in this format:
+        #       lsd 0.17.0
+        # This trims it down to just the version number:
+        #       0.17.0
+        echo $(lsd --version 2>/dev/null | head -n 1 | cut -d ' ' -f 2)
+    }
+
+}
diff --git a/lsd/releases.js b/lsd/releases.js
new file mode 100644 (file)
index 0000000..24ae092
--- /dev/null
@@ -0,0 +1,23 @@
+'use strict';
+
+var github = require('../_common/github.js');
+var owner = 'Peltoche';
+var repo = 'lsd';
+
+module.exports = function (request) {
+  return github(request, owner, repo).then(function (all) {
+    all.releases = all.releases.filter(function (rel) {
+      return !/(-musl\.)|(-msvc\.)|(\.deb$)/.test(rel.name)
+    });
+    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));
+  });
+}