Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

235 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Sek Shell

The sek is a shell without script support.

Why is it called sek?

sek is 石 (the stone in chinese).

The name comes from ancient chinese philosophical discussions: 离坚白, hardness and white color are two attributes of the stone, The philosopher 公孙龙 tried to discuss them separately.

Why sek?

Just as a stone has two attributes: hardness and white color, the shell also has two modes of use: interactive and script.

Modern shells have become powerful and complex, and a large part of this complexity comes from script support.

The posix shell has a lot of historical problems, but shell scripts that are not compatible with posix can hardly be successful. It turns out that python or nodejs is a better script language than (any) shell script.

So sek choose not to provide any form of script support, and instead focused on being an interactive shell.

What's difference?

Since we gave up script support, we can make the shell syntax simpler and stricter.

Please note that the following decisions are entirely based on my experience. It does not apply to everyone.

No if and for support

I almost never use them in interactive mode. But sek supports && and ||, so it can make some simple logical.

No glob support

The glob expansion is the famous footgun of shell. For example, you cannot use rm * to delete --help files in the directory. In addition, it is not suitable for directory with too many files.

And this is not a common feature, the only scene I can recall is rm *.jpg, I can replace it with 10L rust code.

//! rm-glob '*.jpg'
use anyhow::Context;

fn main() -> anyhow::Result<()> {
    let pat = std::env::args().nth(1).context("no glob pattern")?;
    for path in glob::glob(&pat)? {
        std::fs::remove_file(path?)?;
    }
    Ok(())
}

No unpopular syntax

There are some almost quirky syntax in shell, and most users don't know its existence.

for example, > fd ls is a legal bash command. It writes the output of ls to a file.

No job control

I usually enter the job control feature because I accidentally pressed C-z. It's a historical legacy feature with. In modern if I need to run another job, I'll open a new terminal emulator.

Feature?

The sek does not try to create a great ecosystem. On the contrary, it is designed to satisfy my personal use.

  • Cross platform
  • Basic shell command
  • Basic helix mode
  • Local History
  • Path selector
  • Completion UI
  • Prompt
  • History-based suggestion
  • Shell completion
  • Persistent history daemon

External feature

I don’t plan to start from scratch, especially since features like command completion require a lot of ecosystem, which means it’s impossible to have a good user experience in the early stages.

Fortunately, tools like fish and starship provide excellent support for this.

As a result, we gain an additional benefit. because our complex feature runs in separate processes, it can be sandboxed. This means that when execute git (by prompt) and cargo (by complete) in untrusted codebase, we add an extra layer of defense.

License

This project is licensed under the MIT license.

About

The Sek Shell

Resources

Stars

2 stars

Watchers

5 watching

Forks

Releases

Packages

Contributors

Languages