Skip to content

Instantly share code, notes, and snippets.

View fdncred's full-sized avatar

Darren Schroeder fdncred

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / fzf_integration.md
Last active September 24, 2022 07:37
fzf_integration

FZF

Most of this is taken from fzf.fish. A really nice fzf integration with fish-shell.

There's quite a bit of usage of a fish command called commandline. It would be super helpful for porting things like this script if we had such a utility to modify the readline command line buffer.

General Setup

Set the default fzf options

let-env FZF_DEFAULT_OPTS = '--cycle --layout=reverse --border --height=90% --preview-window=wrap --marker="*"'
@fdncred
fdncred / parse-tar.nu
Created July 22, 2022 11:51
tar parser
# TAR Header Block
# Offset Field width Field Name Meaning
# 0 100 name Name of file
# 100 8 mode File mode
# 108 8 uid Owner user ID
# 116 8 gid Owner group ID
# 124 12 size Length of file in bytes
# 136 12 mtime Modify time of file
# 148 8 chksum Checksum for header
# 156 1 link Indicator for links