Skip to content

Commit

Permalink
Env: Save include ~ all dotfiles.
Browse files Browse the repository at this point in the history
  • Loading branch information
Theotime Leveque committed May 1, 2017
1 parent 891b4a3 commit 55fb0c5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions backend/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"os/exec"
"os/user"
"path/filepath"
"strings"

"github.com/fatih/color"
"github.com/spf13/afero"
Expand Down Expand Up @@ -134,6 +135,15 @@ func EnsureDotfilesDir(dotfilesDirPath string) (err error) {
// ImportIntoDotfilesDir moves dotfiles into dotfiles directory and create symlinks.
func ImportIntoDotfilesDir(dotfilesToSave []string, dotfilesDirPath string) (err error) {
usr, _ := user.Current()

if len(dotfilesToSave) == 0 {
files, _ := ioutil.ReadDir(usr.HomeDir)
for _, file := range files {
if strings.HasPrefix(file.Name(), ".") && file.Name() != ".ssh" && file.Name() != ".bash_history" && file.Name() != ".Trash" {
dotfilesToSave = append(dotfilesToSave, file.Name())
}
}
}
for _, dotfileToSave := range dotfilesToSave {
src := filepath.Join(usr.HomeDir, dotfileToSave)
dst := filepath.Join(dotfilesDirPath, dotfileToSave)
Expand Down
2 changes: 1 addition & 1 deletion cmd/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ var envSaveCmd = &cobra.Command{
config.DotfilesDirPath,
config.Vipers["config"].GetStringMapString("dotfiles")["repository"],
config.Vipers["config"].GetString("default_save_message"),
[]string{".testong"},
[]string{},
)
if err != nil {
fmt.Fprintf(os.Stderr, "Save command failed: %s", err)
Expand Down

0 comments on commit 55fb0c5

Please sign in to comment.