{"id":51134587,"url":"https://github.com/phuslu/gosh","last_synced_at":"2026-06-25T16:01:41.434Z","repository":{"id":358057468,"uuid":"1239781846","full_name":"phuslu/gosh","owner":"phuslu","description":"A compact Bash-style shell written in Go","archived":false,"fork":false,"pushed_at":"2026-05-28T10:50:42.000Z","size":115,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-05-28T12:23:40.098Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/phuslu/gosh","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phuslu.png","metadata":{"files":{"readme":"README.md","changelog":"history.go","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-15T12:40:23.000Z","updated_at":"2026-05-28T10:51:09.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/phuslu/gosh","commit_stats":null,"previous_names":["phuslu/gosh"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/phuslu/gosh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phuslu%2Fgosh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phuslu%2Fgosh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phuslu%2Fgosh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phuslu%2Fgosh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phuslu","download_url":"https://codeload.github.com/phuslu/gosh/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phuslu%2Fgosh/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34782137,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-25T02:00:05.521Z","response_time":101,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-25T16:01:40.582Z","updated_at":"2026-06-25T16:01:41.413Z","avatar_url":"https://github.com/phuslu.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gosh\n\n`gosh` is a compact Bash-style shell written in Go.\n\nIt uses [`mvdan.cc/sh/v3`](https://pkg.go.dev/mvdan.cc/sh/v3) for shell\nparsing and interpretation, then adds the pieces that make it usable as an\ninteractive shell: readline editing, history, prompt rendering, tab completion,\n`bind`, and Bash-flavored compatibility helpers.\n\nUse it as a small local shell, a script runner, or an embeddable shell runtime\ninside a Go program.\n\n## Quick tour\n\nBuild the CLI from a checkout:\n\n```sh\ngit clone https://github.com/phuslu/gosh\ncd gosh/cmd/gosh\ngo build -mod=readonly -o gosh .\n./gosh\n```\n\nRun a one-shot command:\n\n```sh\n./gosh -c 'name=gosh; for n in 1 2 3; do printf \"%s:%s\\n\" \"$name\" \"$n\"; done'\n```\n\nRun a script from standard input:\n\n```sh\nprintf 'echo one\\necho two\\n' | ./gosh\n```\n\nStart an interactive session:\n\n```sh\n./gosh\nsh-0.0$ echo \"$BASH_VERSION\"\n0.0.0(1)-gosh\nsh-0.0$ shopt -s extglob\nsh-0.0$ shopt -q extglob \u0026\u0026 echo enabled\nenabled\n```\n\n## Features\n\n- Bash-style syntax through `mvdan.cc/sh/v3`: variables, functions, conditionals,\n  loops, pipelines, redirects, command substitution, arithmetic, globbing, and\n  shell builtins.\n- Interactive line editing with readline.\n- Command and path completion.\n- Prefix history search for the up/down arrow bindings.\n- Bash prompt escape rendering for common `PS1` and `PS2` sequences.\n- `bind` support for common cursor and history-search actions.\n- `history` builtin backed by `HISTFILE`, `HISTSIZE`, and `HISTCONTROL`.\n- `shopt -q` compatibility, including `builtin shopt -q` and\n  `command shopt -q`.\n- `BASH_VERSION` and `$-` compatibility variables for shell startup files.\n- Programmatic use through `gosh.Run`.\n\n## Configuration\n\nInteractive `gosh` loads `GOSH_ENV` when it is set. If `GOSH_ENV` is unset, it\nloads `$HOME/.bashrc` for interactive sessions. Non-interactive scripts from\nstandard input and commands run with `-c` do not load a startup file or render\nprompts.\n\nExample `~/.bashrc` or `GOSH_ENV` file:\n\n```sh\nif [ -n \"${BASH_VERSION-}\" ] \u0026\u0026 case \"$-\" in *i*) true;; *) false;; esac; then\n    bind '\"\\e[1~\": beginning-of-line'\n    bind '\"\\e[4~\": end-of-line'\n    bind '\"\\e[5~\": previous-screen'\n    bind '\"\\e[6~\": next-screen'\n    bind '\"\\e[F\": end-of-line'\n    bind '\"\\e[H\": beginning-of-line'\n    bind '\"\\e[B\": history-search-forward'\n    bind '\"\\e[A\": history-search-backward'\nfi\n\nexport LC_ALL=en_US.UTF-8\nexport TERM=xterm-256color\nexport SHELL=/bin/bash\nexport PATH=\"$HOME/.local/bin:$PATH\"\n\nexport HISTFILE=\"$HOME/.gosh_history\"\nexport HISTSIZE=1000\nexport HISTCONTROL=ignoreboth\n\nexport PS1='\\[\\e]0;\\h:\\w\\a\\]\\n\\[\\e[1;32m\\]\\u@\\H\\[\\e[0;33m\\] \\w \\[\\e[0m[\\D{%T}]\\n\\[\\e[1;$((31+3*!$?))m\\]\\$\\[\\e[0m\\] '\n\nalias ls='ls -p --color'\nalias ll='ls -lF --color'\nalias grep='grep --color'\n```\n\n## Embed in Go\n\n`gosh.Run` accepts explicit input, output, environment, arguments, and working\ndirectory, so it can be used without a process-level shell.\n\n```go\npackage main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\n\t\"github.com/phuslu/gosh\"\n)\n\nfunc main() {\n\tvar stdout, stderr bytes.Buffer\n\n\terr := gosh.Run(gosh.Config{\n\t\tArgs:   []string{\"gosh\", \"-c\", `printf \"hello %s\\n\" \"$1\"`, \"gosh\", \"world\"},\n\t\tStdout: \u0026stdout,\n\t\tStderr: \u0026stderr,\n\t\tEnv: []string{\n\t\t\t\"PATH=/usr/bin:/bin\",\n\t\t\t\"HOME=/tmp\",\n\t\t\t\"HISTFILE=/dev/null\",\n\t\t},\n\t})\n\tif err != nil {\n\t\tfmt.Println(stderr.String())\n\t\tpanic(err)\n\t}\n\tfmt.Print(stdout.String())\n}\n```\n\n## Compatibility notes\n\n`gosh` is Bash-flavored, not a byte-for-byte Bash replacement. Shell syntax and\nmany builtins come from `mvdan.cc/sh/v3`, while external commands are executed\nfrom the host `PATH`.\n\nSome Bash features that depend on a full POSIX job-control shell, a PTY-managed\nprocess tree, or Bash internals may behave differently. Treat `gosh` as a small,\nembeddable shell with strong Bash compatibility for common scripts and\ninteractive workflows, not as a login-shell replacement.\n\n## Development\n\nRun the library tests from the repository root:\n\n```sh\ngo test ./...\n```\n\nBuild the CLI from its module:\n\n```sh\ncd cmd/gosh\ngo build -mod=readonly -o gosh .\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphuslu%2Fgosh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphuslu%2Fgosh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphuslu%2Fgosh/lists"}