For programming/scripting questions regarding Nushell (a.k.a. "nu"), a shell available for Linux, Unix, and Windows operating systems. Interactive, general-use shell questions are typically better suited for the Super User or Unix & Linux sites, but (as always) please review their on-topic guidance and check for duplicates before posting.
Questions tagged [nushell]
21 questions
7
votes
3 answers
How do I delete specific history entries in Nushell?
Given a history like this in Nushell, how do I delete specific entries; e.g. entries 6, 8, and 10?
nu > history
╭────┬────────────────────╮
│ # │ command │
├────┼────────────────────┤
│ 0 │ history --clear │
│ 1 │ php --version …

Charles Roper
- 20,125
- 20
- 71
- 101
6
votes
1 answer
How do I check if a directory exists in a Nushell script?
I would like to know how I check if a directory exists in Nushell?

stax76
- 416
- 4
- 12
5
votes
2 answers
how to run powershell command from nushell
After installing nushell (https://www.nushell.sh/) in my windows environment, I want to use the power of nushell in conjunction with powershell.
For example, I need to invoke common powershell commands in my daily work like
> get-service *myservice…

waffel
- 51
- 3
5
votes
3 answers
Get current script location in Nu shell
In bash you can use $0 variable to get the location of the current script. How I do the same in Nu? echo $nu doesn't seem to have anything I can use.

Jacob Wang
- 4,411
- 5
- 29
- 43
4
votes
2 answers
How to filter on the number of rows in the value column of a group-by in nushell?
I want to do the equivalent of a HAVING clause in SQL. The real life description is I'm trying to find Elasticsearch aliases that point to two(or more) indexes and their index names. The data looks like this.
I first do a group by, then I pivot them…

sgarg
- 2,340
- 5
- 30
- 42
3
votes
1 answer
Create new column base upon existing column in NuShell
I am new to NuShell and would like to create a quick way to locate my files by their "tags", which are in the filename. This is the method used by tagspaces. For instance, using the ls command my directory might look like…

Benjamin Neil
- 71
- 1
- 8
3
votes
1 answer
Cannot rewrite some function from bash to nushell
I'm moving from bash to nushell. One of my steps was moving this function:
ex ()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar…

YaSyelTebya
- 33
- 3
3
votes
1 answer
Bash $@ equivalent in nushell
I want to access all the arguments and run the same command on each argument in the list.
#!/usr/bin/env nu
def main [ one, two ] {
// echo each item in the argument list
}
How to achieve this in nushell?

s1n7ax
- 2,750
- 6
- 24
- 53
3
votes
1 answer
while/until loops in Nushell
How do you do while/until loops in Nushell script?
Since Nushell has a fairly amazing table/JSON parsing system, I've been trying to work with the Stack Exchange API through it.
One of the first challenges is looping over the multiple possible pages…

NotTheDr01ds
- 15,620
- 5
- 44
- 70
3
votes
2 answers
In nushell how can I combine where clauses
I have this nushell query:
open ./s3_actions.csv | where actions !~ 'Acl' | where actions !~ 'Cors' | where actions !~ 'Job' | where actions !~ 'Retention' | where actions !~ 'Legal' | where actions !~ 'Payment' | where actions !~ 'Policy' | where…

Matthew Sherborne
- 33
- 3
2
votes
1 answer
expand collapsed data in nushell
I'm trying to learn nushell, and from this example in the documentation,
> echo [[column1, column2]; [Value1, Value2]]
───┬─────────┬─────────
# │ column1 │ column2
───┼─────────┼─────────
0 │ Value1 │ Value2
───┴─────────┴─────────
but my…

lofiwatercat
- 23
- 4
1
vote
1 answer
How to remove/mutate things (shells, aliases) in nushell
I'm using shells and enter to manage a "dirstack". I want to "popd" to remove dirs I've added.
I also have some aliases that I no longer want in my session. How do I delete the aliases?
I've tried things like drop but if the dirs and aliases are…

Micah Elliott
- 9,600
- 5
- 51
- 54
1
vote
1 answer
how to redirect stderr to a file in NuShell?
Here is what I tried
ls | to json | save fileList.json
open fileList.json | from json | save error.log
open fileList.json | from json | save --stderr error.log
It didn't save anything to file error.log
FYI, added the (useless)second part | from…

Robert Ranjan
- 1,538
- 3
- 19
- 17
1
vote
2 answers
How to get rid of error messages in nushell?
In Bash I would do something like
...
...
if ! cd non_exist_dir > /dev/null 2>&1; then
echo "error in cd"
return 1
fi
...
...
How would I do that in idiomatic nushell ?
Especially, how can I get rid of the annoying error message displayed by…

zentrunix
- 2,098
- 12
- 20
0
votes
1 answer
How to show a function/command definition in nushell
How can I see the definition for a function (aka command)?
In Zsh, I can do this:
# Define some function
% tarx () { tar xzvf $1 }
# Come back later, see what it is
% declare -f tarx
tarx () { tar xzvf $1 }
In nushell, the equivalent seems to…

Micah Elliott
- 9,600
- 5
- 51
- 54