Skip to content

Instantly share code, notes, and snippets.

View fdncred's full-sized avatar

Darren Schroeder fdncred

View GitHub Profile
@fdncred
fdncred / build_all_plugins.nu
Last active September 27, 2024 13:15
build all plugins
# Build All Plugins
def build_all_external_plugins [] {
let plugins = ls nu_plugin_* | where name != nu_plugin_template
for plug in $plugins {
print $"(ansi green_bold)Doing some git work on (ansi purple_bold)($plug.name)(ansi reset)(char nl)"
cd ($plug.name | path expand)
git restore Cargo.lock
git restore Cargo.toml
git pull
@fdncred
fdncred / config.nu
Last active October 24, 2024 11:09
env_change PWD hook for nushell
hooks: {
pre_prompt: [{||
null
}]
pre_execution: [{||
null
}]
env_change: {
PWD: [
{ |before, after|
@fdncred
fdncred / inferring-values.md
Last active August 31, 2023 19:11
inferring values

Inferring nushell values proposal

Problem

A common task in nushell is to create a pipeline and then go back and update each column with into blah, where blah is the nushell value you want to update it with. While this is helpful, it's a bit cumbersome. We do have some shortcuts though. e.g. If all the columns you want to update are ints, you can just do $table | into int col1 col2 col3. That's great if you have a lot of the same type. However, that doesn't happen all the time.

Solution

What I'd like to introduce is a method of inferring nushell value type in each cell. I've thought about doign this a few different ways.

@fdncred
fdncred / nushell_with_uu.md
Last active September 4, 2023 17:26
nushell_with_uu

Nushell + UUtils = ❤️

We're happy to announce that with Nushell release 0.85.0, the nushell team is starting to integrate uutils/coreutils into nushell. The first command we have integrated is cp. So, when you use cp in this release, you're using the same code that it used in coreutils. 🎉 🥳

Many thanks to @tertsdiepraam, from the uutils team, and nushell contributor, @dmatos2012 for creating this first integration PR.

But why?

Nushell has been around since it's first public release in August 23rd, 2019. I think it's pretty safe to say that the concept of nushell has remained the same throughout the years, but wow have the internals changed. We've added commands, polished commands, removed commands, all to make nushell more composable and cohesive.

@fdncred
fdncred / pr.nu
Last active October 30, 2023 12:02
rich_print
# emulate the python rich print
# https://github.com/Textualize/rich
# https://github.com/Textualize/rich/blob/master/rich/console.py#L1624
# test case 1: pr "hello world"
# test case 2: pr "hello world" --style bold
# test case 3: pr "hello world" --style 'bold underline'
# test case 4: pr "hello world" --style 'dim italic red'
def pr [
msg,
--style: string,
@fdncred
fdncred / dt-formats.nu
Created October 30, 2023 19:58
datetime formats
def utc [now?: datetime] {
if $now == null {
date now | date to-timezone utc | format date "%Y-%m-%dT%H:%M:%SZ"
} else {
$now | date to-timezone utc | format date "%Y-%m-%dT%H:%M:%SZ"
}
}
def iso-8601 [now?: datetime] {
if $now == null {
@fdncred
fdncred / known_bugs.md
Last active November 3, 2023 12:24
known nushell bugs

Recurring Known Bugs that need to be fixed before 1.0

input_output_types order of execution vs matching

The `input_output_types`` are parsed from top to bottom instead of matching on the appropriate ones. This makes some thing fail because the first one succeeds gets output versus the right one.

Example:

 http get https://index.crates.io/ba/se/base64 | lines | last | from json
Error: nu::parser::input_type_mismatch
@fdncred
fdncred / store_commands.md
Last active November 3, 2023 17:15
stor family of commands

Stor family of commands

Introduction

Originally when I wrote the $db PR, I went in knowing that other commands would be needed. The concept is to have an in-memory sqlite database available to you at any time to store anything you want. I just chose $db because it was very nushell-y and easily accessible.

An alternative that I came up with was to have a command named stor with subcommands. stor without and e because you don't get groceries from it. :) We can name it whatever, but for now, it's stor. The idea behind the stor family of commands is that they provide a way to interact with the in-memory database.

Commands

@fdncred
fdncred / languages.toml
Created November 8, 2023 20:56
helix languages
# Language support configuration.
# See the languages documentation: https://docs.helix-editor.com/master/languages.html
[language-server]
awk-language-server = { command = "awk-language-server" }
bash-language-server = { command = "bash-language-server", args = ["start"] }
bass = { command = "bass", args = ["--lsp"] }
bicep-langserver = { command = "bicep-langserver" }
bufls = { command = "bufls", args = ["serve"] }
@fdncred
fdncred / escape_sequences.md
Created December 20, 2023 15:38
escape sequences

OSC4 - set foreground/background colors

OSC 4 ; -2; ? ST //bg
OSC 4 ; -1 ; ? ST //fg
OSC 4 ; -2 ; rgb : [red] / [green] / [blue] ST
OSC 4 ; -1 ; rgb : [red] / [green] / [blue] ST

OSC6 - set window title and tab color

OSC 6 ; 1 ; bg ; red ; brightness ; [N] ST
OSC 6 ; 1 ; bg ; green ; brightness ; [N] ST

OSC 6 ; 1 ; bg ; blue ; brightness ; [N] ST