module

Scsh

Constants

HISTORY_FILE = (ENV["HOME"]? ? File.join(ENV["HOME"], ".scsh_history") : ".scsh_history")

---------------- History (file) ----------------

QUOTES = ["Keep calm and code on.", "Did you try turning it off and on again?", "There’s no place like 127.0.0.1.", "To iterate is human, to recurse divine.", "sudo rm -rf / – Just kidding, don’t do that!", "The shell is mightier than the sword.", "A journey of a thousand commits begins with a single push.", "In case of fire: git commit, git push, leave building.", "Debugging is like being the detective in a crime movie where you are also the murderer.", "Unix is user-friendly. It's just selective about who its friends are.", "Old sysadmins never die, they just become daemons.", "Listen you flatpaker! – Totally Terry Davis", "How is #{Crystal::VERSION}? 🤔", "Life is short, but your command history is eternal.", "If at first you don’t succeed, git commit and push anyway.", "rm -rf: the ultimate trust exercise.", "Coding is like magic, but with more coffee.", "There’s no bug, only undocumented features.", "Keep your friends close and your aliases closer.", "Why wait for the future when you can Ctrl+Z it?", "A watched process never completes.", "When in doubt, make it a function.", "Some call it procrastination, we call it debugging curiosity.", "Life is like a terminal; some commands just don’t execute.", "Good code is like a good joke; it needs no explanation.", "sudo: because sometimes responsibility is overrated.", "Pipes make the world go round.", "In bash we trust, in Crystal we wonder.", "A system without errors is like a day without coffee.", "Keep your loops tight and your sleeps short.", "Stack traces are just life giving you directions.", "Your mom called, she wants her semicolons back."] of String

---------------- Quotes ----------------

RC_FILE = (ENV["HOME"]? ? File.join(ENV["HOME"], ".scshrc") : ".scshrc")

---------------- RC file (create if missing) ----------------

SCSH_VERSION = "0.1.1-BETA"

Class methods

builtin_clearhist
Source
builtin_help

---------------- Builtins ----------------

Source
builtin_hist
Source
builtin_jobs
Source
builtin_systemfetch
Source
calculate_cpu_usage(prev : Array(Int64), cur : Array(Int64)) : Float64
Source
color(text : String, code : Int32 | String) : String

---------------- Utilities ----------------

Source
cpu_cores_and_freq
Source
cpu_info
Source
current_time

---------------- System Info ----------------

Source
detect_distro
Source
disable_ctrl_c_echo

---------------- Ctrl+C echo helpers ----------------

Source
dynamic_quote
Source
executable_file?(path : String) : Bool

Executable check

Source
expand_aliases(cmd : String, seen = [] of String) : String

---------------- Aliases ----------------

Source
expand_vars(str : String) : String

Robust $VAR expansion

Source
find_executable(cmd : String) : String | Nil

---------------- PATH lookup ----------------

Source
handle_tab_completion(prompt_str : String, buffer : String, cursor : Int32, last_tab_prefix : String | Nil, tab_cycle : Int32) : Tuple(String, Int32, String | Nil, Int32, Bool)
Source
history_ghost_for(line : String | Nil) : String | Nil
Source
hostname
Source
human_bytes(bytes : Int64 | Int32 | UInt64 | UInt32 | Float64) : String
Source
longest_common_prefix(strings : Array(String)) : String
Source
nice_bar(p : Float64, w : Int32 = 30, code : Int32 = 32) : String
Source
parse_redirection(cmd : String) : Tuple(String, String | Nil, String | Nil, Bool)
Source
prompt

---------------- Prompt / Welcome ----------------

Source
rainbow_codes
Source
ram_info
Source
random_color
Source
read_cpu_times
Source
read_key
Source
read_line_with_ghost(prompt_str : String) : Tuple(InputStatus, String | Nil)
Source
render_line(prompt_str : String, buffer : String, cursor : Int32, show_ghost : Bool = true)
Source
restore_ctrl_c_echo
Source
run

---------------- Main Loop (srsh-style input) ----------------

Source
run_command(cmd_in : String)

---------------- External Command Execution ----------------

Source
run_input_line(input : String)

---------------- Chained Commands ----------------

Source
shellsplit(s : String) : Array(String)

Shellwords-ish splitter

Source
storage_info
Source
strip_ansi(str : String) : String

Strip ANSI color codes (for width calculations)

Source
tab_completions_for(prefix : String, first_word : String, at_first_word : Bool) : Array(String)
Source
terminal_width
Source

Nested types