Source File
builtin_fn_fs.go
Belonging Package
src.elv.sh/pkg/eval
package evalimport ()// Filesystem commands.// ErrStoreNotConnected is thrown by dir-history when the store is not connected.var ErrStoreNotConnected = errors.New("store not connected")//elvdoc:fn path-\*//// ```elvish// path-abs $path// path-base $path// path-clean $path// path-dir $path// path-ext $path// ```//// See [godoc of path/filepath](https://godoc.org/path/filepath). Go errors are// turned into exceptions.//// These functions are deprecated. Use the equivalent functions in the// [path:](path.html) module.func () {addBuiltinFns(map[string]interface{}{// Directory"cd": cd,"dir-history": dirs,// Path"tilde-abbr": tildeAbbr,})}//elvdoc:fn cd//// ```elvish// cd $dirname// ```//// Change directory. This affects the entire process; i.e., all threads// whether running indirectly (e.g., prompt functions) or started explicitly// by commands such as [`peach`](#peach).//// Note that Elvish's `cd` does not support `cd -`.//// @cf pwdfunc ( *Frame, ...string) error {var stringswitch len() {case 0:var error, = fsutil.GetHome("")if != nil {return}case 1:= [0]default:return ErrArgs}return .Evaler.Chdir()}//elvdoc:fn dir-history//// ```elvish// dir-history// ```//// Return a list containing the directory history. Each element is a map with two// keys: `path` and `score`. The list is sorted by descending score.//// Example://// ```elvish-transcript// ~> dir-history | take 1// ▶ [&path=/Users/foo/.elvish &score=96.79928]// ```type dirHistoryEntry struct {Path stringScore float64}func (dirHistoryEntry) () {}func ( *Frame) error {:= .Evaler.DaemonClient()if == nil {return ErrStoreNotConnected}, := .Dirs(store.NoBlacklist)if != nil {return}:= .OutputChan()for , := range {<- dirHistoryEntry{.Path, .Score}}return nil}//elvdoc:fn tilde-abbr//// ```elvish// tilde-abbr $path// ```//// If `$path` represents a path under the home directory, replace the home// directory with `~`. Examples://// ```elvish-transcript// ~> echo $E:HOME// /Users/foo// ~> tilde-abbr /Users/foo// ▶ '~'// ~> tilde-abbr /Users/foobar// ▶ /Users/foobar// ~> tilde-abbr /Users/foo/a/b// ▶ '~/a/b'// ```func ( string) string {return fsutil.TildeAbbr()}
The pages are generated with Golds v0.2.8-preview. (GOOS=darwin GOARCH=arm64)