shellrc

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package shellrc adds and removes the block in the user's .zshrc and .bashrc that defines the mdsh function, which passes the calling shell's aliases and functions to blocks, and loads mdsh's completion.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Zsh is ~/.zshrc, or $ZDOTDIR/.zshrc. Its completion line waits for
	// compinit, as has run by the end of most .zshrc files; without it,
	// compdef is missing and the line does nothing.
	Zsh = RC{
		Wrapper:    `function mdsh { command mdsh --source <(alias -L; typeset -f) "$@"; }`,
		Completion: `(( $+functions[compdef] )) && source <(command mdsh completion zsh)`,
		// contains filtered or unexported fields
	}
	// Bash is ~/.bashrc. Its wrapper leaves out its own function and
	// the completion's: their bash-only syntax would stop a /bin/sh that
	// is dash from sourcing the rest. Its completion line only runs in an
	// interactive shell, where complete does something.
	Bash = RC{
		Wrapper:    `function mdsh { command mdsh --source <(unset -f mdsh _mdsh; alias -p; declare -f) "$@"; }`,
		Completion: `[[ $- == *i* ]] && source <(command mdsh completion bash)`,
		// contains filtered or unexported fields
	}
)

Functions

This section is empty.

Types

type RC

type RC struct {
	// Wrapper defines the mdsh function. The function keyword keeps an
	// alias named mdsh from breaking the definition.
	Wrapper string
	// Completion loads mdsh's completion for the shell.
	Completion string
	// contains filtered or unexported fields
}

RC is one shell's startup file and the lines that go in it.

func (RC) Installed

func (r RC) Installed(path string) (bool, error)

Installed reports whether the file at path has the block. A missing file doesn't.

func (RC) Path

func (r RC) Path() (string, error)

Path is the file the shell reads.

func (RC) Set

func (r RC) Set(path string, on bool) error

Set adds the block to the end of the file at path, creating the file if need be, or removes it, leaving the rest of the file as it was. A block from an older mdsh-gui is brought up to date in place.

func (RC) Update

func (r RC) Update(path string) error

Update brings the block in the file at path up to date, if it has one, so a file set up by an older mdsh-gui gets the completion line.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL