mirror of
https://github.com/nushell/nushell
synced 2024-12-26 04:53:09 +00:00
README
This commit is contained in:
parent
aa757bf6ad
commit
52716d0c24
4 changed files with 159 additions and 2 deletions
133
README.md
Normal file
133
README.md
Normal file
|
@ -0,0 +1,133 @@
|
|||
# Nu Shell
|
||||
|
||||
A shell for the GitHub era. A shell you can hack on.
|
||||
|
||||
# Status
|
||||
|
||||
This project has little of what will eventually be necessary for Nu to serve as your day-to-day shell. It already works well enough for contributors to dogfood it as their daily driver, but there are too many basic deficiencies for it to be useful for most people.
|
||||
|
||||
At the moment, executing a command that isn't identified as a built-in new command will fall back to running it as a shell command (using cmd on Windows or bash on Linux and MacOS), correctly passing through stdin, stdout and stderr, so things like your daily git workflows and even `vim` will work just fine.
|
||||
|
||||
There is not yet support for piping external commands to each other; piping is limited to Nu commands at the moment.
|
||||
|
||||
Nu currently has the following built-in commands:
|
||||
|
||||
- cd
|
||||
- ls
|
||||
- ps
|
||||
- select ...fields
|
||||
- reject ...fields
|
||||
- sort-by ...fields
|
||||
- where condition
|
||||
- skip amount
|
||||
- take amount
|
||||
- to-array
|
||||
|
||||
# Goals
|
||||
|
||||
Prime Directive: Cross platform workflows, with first-class consistent support for Windows, OSX and Linux.
|
||||
|
||||
Priority #1: direct compatibility with existing platform-specific executables that make up people's workflows
|
||||
|
||||
Priority #2: Create workflow tools that more closely match the day-to-day experience of using a shell in 2019 (and beyond)
|
||||
|
||||
Priority #3: It's an object shell like PowerShell.
|
||||
|
||||
> These goals are all critical, project-defining priorities. Priority #1 is "direct compatibility" because any new shell absolutely needs a way to use existing executables in a direct and natural way.
|
||||
|
||||
# A Taste of Nu
|
||||
|
||||
```text
|
||||
~\Code\nushell> ps | where cpu -gt 0
|
||||
+-------------------+-----+-------+-------+----------+
|
||||
| name | cmd | cpu | pid | status |
|
||||
+-------------------+-----+-------+-------+----------+
|
||||
| chrome.exe | - | 7.83 | 10508 | Runnable |
|
||||
+-------------------+-----+-------+-------+----------+
|
||||
| SearchIndexer.exe | - | 7.83 | 4568 | Runnable |
|
||||
+-------------------+-----+-------+-------+----------+
|
||||
| nu.exe | - | 54.83 | 15436 | Runnable |
|
||||
+-------------------+-----+-------+-------+----------+
|
||||
| chrome.exe | - | 7.83 | 10000 | Runnable |
|
||||
+-------------------+-----+-------+-------+----------+
|
||||
| BlueJeans.exe | - | 7.83 | 6968 | Runnable |
|
||||
+-------------------+-----+-------+-------+----------+
|
||||
|
||||
~\Code\nushell> ps | where name -eq chrome.exe | take 10
|
||||
|
||||
+------------+-----+------+-------+----------+
|
||||
| name | cmd | cpu | pid | status |
|
||||
+------------+-----+------+-------+----------+
|
||||
| chrome.exe | - | 0.00 | 22092 | Runnable |
|
||||
+------------+-----+------+-------+----------+
|
||||
| chrome.exe | - | 0.00 | 17324 | Runnable |
|
||||
+------------+-----+------+-------+----------+
|
||||
| chrome.exe | - | 0.00 | 16376 | Runnable |
|
||||
+------------+-----+------+-------+----------+
|
||||
| chrome.exe | - | 0.00 | 21876 | Runnable |
|
||||
+------------+-----+------+-------+----------+
|
||||
| chrome.exe | - | 0.00 | 13432 | Runnable |
|
||||
+------------+-----+------+-------+----------+
|
||||
| chrome.exe | - | 0.00 | 11772 | Runnable |
|
||||
+------------+-----+------+-------+----------+
|
||||
| chrome.exe | - | 0.00 | 13796 | Runnable |
|
||||
+------------+-----+------+-------+----------+
|
||||
| chrome.exe | - | 0.00 | 1608 | Runnable |
|
||||
+------------+-----+------+-------+----------+
|
||||
| chrome.exe | - | 0.00 | 3340 | Runnable |
|
||||
+------------+-----+------+-------+----------+
|
||||
| chrome.exe | - | 0.00 | 20268 | Runnable |
|
||||
+------------+-----+------+-------+----------+
|
||||
|
||||
~\Code\nushell> ls | sort-by "file type" size
|
||||
+---------------+-----------+----------+----------+----------------+----------------+----------------+
|
||||
| file name | file type | readonly | size | created | accessed | modified |
|
||||
+---------------+-----------+----------+----------+----------------+----------------+----------------+
|
||||
| .git | Directory | | Empty | a week ago | 2 minutes ago | 2 minutes ago |
|
||||
+---------------+-----------+----------+----------+----------------+----------------+----------------+
|
||||
| src | Directory | | Empty | a week ago | 42 minutes ago | 42 minutes ago |
|
||||
+---------------+-----------+----------+----------+----------------+----------------+----------------+
|
||||
| target | Directory | | Empty | a day ago | 19 hours ago | 19 hours ago |
|
||||
+---------------+-----------+----------+----------+----------------+----------------+----------------+
|
||||
| .gitignore | File | | 30 B | a week ago | 2 days ago | 2 days ago |
|
||||
+---------------+-----------+----------+----------+----------------+----------------+----------------+
|
||||
| .editorconfig | File | | 148 B | 6 days ago | 6 days ago | 6 days ago |
|
||||
+---------------+-----------+----------+----------+----------------+----------------+----------------+
|
||||
| Cargo.toml | File | | 714 B | 42 minutes ago | 42 minutes ago | 42 minutes ago |
|
||||
+---------------+-----------+----------+----------+----------------+----------------+----------------+
|
||||
| history.txt | File | | 1.4 KiB | 2 days ago | 30 minutes ago | 30 minutes ago |
|
||||
+---------------+-----------+----------+----------+----------------+----------------+----------------+
|
||||
| README.md | File | | 2.3 KiB | an hour ago | 30 seconds ago | 30 seconds ago |
|
||||
+---------------+-----------+----------+----------+----------------+----------------+----------------+
|
||||
| Cargo.lock | File | | 38.6 KiB | 42 minutes ago | 42 minutes ago | 42 minutes ago |
|
||||
+---------------+-----------+----------+----------+----------------+----------------+----------------+
|
||||
|
||||
~\Code\nushell> ls | select "file name" "file type" size | sort-by "file type"
|
||||
+---------------+-----------+----------+
|
||||
| file name | file type | size |
|
||||
+---------------+-----------+----------+
|
||||
| .git | Directory | Empty |
|
||||
+---------------+-----------+----------+
|
||||
| src | Directory | Empty |
|
||||
+---------------+-----------+----------+
|
||||
| target | Directory | Empty |
|
||||
+---------------+-----------+----------+
|
||||
| .editorconfig | File | 148 B |
|
||||
+---------------+-----------+----------+
|
||||
| .gitignore | File | 30 B |
|
||||
+---------------+-----------+----------+
|
||||
| Cargo.lock | File | 38.6 KiB |
|
||||
+---------------+-----------+----------+
|
||||
| Cargo.toml | File | 714 B |
|
||||
+---------------+-----------+----------+
|
||||
| history.txt | File | 1.4 KiB |
|
||||
+---------------+-----------+----------+
|
||||
| README.md | File | 2.3 KiB |
|
||||
+---------------+-----------+----------+
|
||||
```
|
||||
|
||||
Nu currently has fish-style completion of previous commands, as well ctrl-r reverse search.
|
||||
|
||||
![autocompletion][fish-style]
|
||||
|
||||
[fish-style]: ./images/nushell-autocomplete.gif "Fish-style autocomplete"
|
BIN
images/nushell-autocomplete.gif
Normal file
BIN
images/nushell-autocomplete.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 490 KiB |
|
@ -3,14 +3,17 @@ use crate::object::desc::DataDescriptor;
|
|||
use ansi_term::Color;
|
||||
use chrono::{DateTime, Utc};
|
||||
use chrono_humanize::Humanize;
|
||||
use ordered_float::OrderedFloat;
|
||||
use std::time::SystemTime;
|
||||
|
||||
type OF64 = OrderedFloat<f64>;
|
||||
|
||||
#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
|
||||
pub enum Primitive {
|
||||
Nothing,
|
||||
Int(i64),
|
||||
#[allow(unused)]
|
||||
Float(ordered_float::OrderedFloat<f64>),
|
||||
Float(OF64),
|
||||
Bytes(u128),
|
||||
String(String),
|
||||
Boolean(bool),
|
||||
|
@ -36,7 +39,7 @@ impl Primitive {
|
|||
}
|
||||
}
|
||||
Primitive::Int(i) => format!("{}", i),
|
||||
Primitive::Float(f) => format!("{}", f),
|
||||
Primitive::Float(f) => format!("{:.*}", 2, f.into_inner()),
|
||||
Primitive::String(s) => format!("{}", s),
|
||||
Primitive::Boolean(b) => match (b, field_name) {
|
||||
(true, None) => format!("Yes"),
|
||||
|
@ -155,6 +158,10 @@ impl Value {
|
|||
Value::Primitive(Primitive::Int(s.into()))
|
||||
}
|
||||
|
||||
crate fn float(s: impl Into<OF64>) -> Value {
|
||||
Value::Primitive(Primitive::Float(s.into()))
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
crate fn bool(s: impl Into<bool>) -> Value {
|
||||
Value::Primitive(Primitive::Boolean(s.into()))
|
||||
|
@ -249,6 +256,22 @@ crate fn find(obj: &Value, field: &str, op: &str, rhs: &Value) -> bool {
|
|||
("-ne", Value::Primitive(Primitive::Int(i2))) => i != *i2,
|
||||
_ => false,
|
||||
},
|
||||
Value::Primitive(Primitive::Float(i)) => match (op, rhs) {
|
||||
("-lt", Value::Primitive(Primitive::Float(i2))) => i < *i2,
|
||||
("-gt", Value::Primitive(Primitive::Float(i2))) => i > *i2,
|
||||
("-le", Value::Primitive(Primitive::Float(i2))) => i <= *i2,
|
||||
("-ge", Value::Primitive(Primitive::Float(i2))) => i >= *i2,
|
||||
("-eq", Value::Primitive(Primitive::Float(i2))) => i == *i2,
|
||||
("-ne", Value::Primitive(Primitive::Float(i2))) => i != *i2,
|
||||
("-lt", Value::Primitive(Primitive::Int(i2))) => (i.into_inner()) < *i2 as f64,
|
||||
("-gt", Value::Primitive(Primitive::Int(i2))) => i.into_inner() > *i2 as f64,
|
||||
("-le", Value::Primitive(Primitive::Int(i2))) => i.into_inner() <= *i2 as f64,
|
||||
("-ge", Value::Primitive(Primitive::Int(i2))) => i.into_inner() >= *i2 as f64,
|
||||
("-eq", Value::Primitive(Primitive::Int(i2))) => i.into_inner() == *i2 as f64,
|
||||
("-ne", Value::Primitive(Primitive::Int(i2))) => i.into_inner() != *i2 as f64,
|
||||
|
||||
_ => false,
|
||||
},
|
||||
Value::Primitive(Primitive::String(s)) => match (op, rhs) {
|
||||
("-eq", Value::Primitive(Primitive::String(s2))) => s == *s2,
|
||||
("-ne", Value::Primitive(Primitive::String(s2))) => s != *s2,
|
||||
|
|
|
@ -16,6 +16,7 @@ crate fn process_dict(proc: &sysinfo::Process) -> Dictionary {
|
|||
};
|
||||
|
||||
dict.add("cmd", cmd_value);
|
||||
dict.add("cpu", Value::float(proc.cpu_usage() as f64));
|
||||
dict.add("pid", Value::int(proc.pid() as i64));
|
||||
dict.add("status", Value::string(proc.status().to_string()));
|
||||
|
||||
|
|
Loading…
Reference in a new issue