summaryrefslogtreecommitdiff
path: root/cmds/cd.go
blob: 3a5e9d079a6b1c94aadbebdd1e79d31c5340441d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package cmds

import "os"

// chDir: changes the current working directory
// if no directory is specifed sets it to home
func ChDir(args []string) error {
	var dir string
	if len(args) == 1 {
		dir, _ = os.UserHomeDir()
	} else {
		dir = args[1]
	}
	return os.Chdir(dir)
}