<commit_before>extern crate hostname;
extern crate glob;
extern crate rust_shell as shell;

use std::io;
use std::io::Write;
use std::str;
use hostname::get_hostname;
use shell::state::ShellState;
use shell::circular_buffer::CircularBuffer;
use shell::envars::Envars;

fn main() {
    // TODO: Factor out more helper functions
    // TODO: Semicolons between commands on a single line
    // TODO: Pipes and output redirection
    // TODO: Syntax highlighting
    let mut shell = ShellState {
        variables: Envars::load(),
        history: CircularBuffer::new(10000),
    };

    // login only gives me $HOME, $SHELL, $PATH, $LOGNAME, and $MAIL, so provide defaults here
    shell.variables.insert("PROMPT", "PROMPT={BOLD}{WHITE}╭{RED} ➜ {GREEN}{$USER}@{$HOSTNAME}:{CYAN}{$PWD}{WHITE}\n╰ ➤ ");
    shell.variables.insert("HISTSIZE", "1000");
    shell.variables.insert("USER", "ben");
    shell.variables.insert("HOSTNAME", get_hostname().unwrap().as_ref());

    shell.read_config();

    shell.load_history();

    let mut input_buffer = String::new();
    loop {
        shell.prompt_read(&mut input_buffer);
        let mut args = input_buffer.split_whitespace();
        let cmd = args.next().unwrap_or("").to_owned();

        match cmd.as_ref() {
            "" => print!(""),
            "cd" => shell.cd(args),
            "echo" => shell.echo(args),
            "exit" => {
                io::stdout().flush().unwrap();
                shell.save_history();
                std::process::exit(0)
            },
            "history" => shell.print_history(),
            _ => shell.run_command(&cmd, args)
        };
    }
}
<commit_msg>fixed changes to initial config so this works as a login shell<commit_after>extern crate hostname;
extern crate glob;
extern crate rust_shell as shell;

use std::io;
use std::io::Write;
use std::str;
use hostname::get_hostname;
use shell::state::ShellState;
use shell::circular_buffer::CircularBuffer;
use shell::envars::Envars;

fn main() {
    // TODO: Factor out more helper functions
    // TODO: Semicolons between commands on a single line
    // TODO: Pipes and output redirection
    // TODO: Syntax highlighting
    let mut shell = ShellState {
        variables: Envars::load(),
        history: CircularBuffer::new(10000),
    };

    // login only gives me $HOME, $SHELL, $PATH, $LOGNAME, and $MAIL, so provide defaults here
    shell.variables.insert("PROMPT", "{BOLD}{WHITE}╭{RED} ➜ {GREEN}{$USER}@{$HOSTNAME}:{CYAN}{$PWD}{WHITE}\n╰ ➤ ");
    shell.variables.insert("HISTSIZE", "1000");
    shell.variables.insert("HOSTNAME", get_hostname().unwrap().as_ref());
    let username = shell.variables.get("LOGNAME").unwrap().clone();
    shell.variables.insert("USER", username.to_string_lossy().as_ref());
    let home = shell.variables.get("HOME").unwrap().clone();
    shell.variables.insert("PWD", home.to_string_lossy().as_ref());

    shell.read_config();

    shell.load_history();

    let mut input_buffer = String::new();
    loop {
        shell.prompt_read(&mut input_buffer);
        let mut args = input_buffer.split_whitespace();
        let cmd = args.next().unwrap_or("").to_owned();

        match cmd.as_ref() {
            "" => print!(""),
            "cd" => shell.cd(args),
            "echo" => shell.echo(args),
            "exit" => {
                io::stdout().flush().unwrap();
                shell.save_history();
                std::process::exit(0)
            },
            "history" => shell.print_history(),
            _ => shell.run_command(&cmd, args)
        };
    }
}

{'fraction_non_alphanumeric': 0.16251748251748252, 'fraction_numerical': 0.005594405594405594, 'mean_word_length': 2.8869565217391306, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1486384', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1099, 'n_words': 245}