-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0a41da
commit 5c36c4f
Showing
19 changed files
with
236 additions
and
322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package emacs | ||
|
||
import ( | ||
"os" | ||
"path" | ||
|
||
"github.com/pablobfonseca/dotfiles/src/config" | ||
"github.com/pablobfonseca/dotfiles/src/utils" | ||
"github.com/spf13/cobra" | ||
"github.com/vbauerster/mpb/v7" | ||
) | ||
|
||
var InstallEmacsCmd = &cobra.Command{ | ||
Use: "emacs", | ||
Short: "Install emacs files", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
p := mpb.New() | ||
|
||
verbose, _ := cmd.Flags().GetBool("verbose") | ||
|
||
if emacsInstalled() { | ||
utils.SkipMessage("Emacs is already installed") | ||
} else { | ||
installEmacsBar := utils.NewBar("Installing emacs", 1, p) | ||
|
||
if err := utils.ExecuteCommand(verbose, "brew", "install", "--cask", "emacs"); err != nil { | ||
utils.ErrorMessage("Error installing emacs symlink", err) | ||
} | ||
installEmacsBar.Increment() | ||
|
||
} | ||
|
||
utils.CloneRepoIfNotExists(verbose) | ||
|
||
symlinkBar := utils.NewBar("Symlinking files", 1, p) | ||
|
||
src := path.Join(config.DotfilesConfigDir(), "emacs.d") | ||
dest := path.Join(config.EmacsConfigDir()) | ||
if err := os.Symlink(src, dest); err != nil { | ||
utils.ErrorMessage("Error creating symlink", err) | ||
} | ||
symlinkBar.Increment() | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package emacs | ||
|
||
import ( | ||
"github.com/pablobfonseca/dotfiles/src/config" | ||
"github.com/pablobfonseca/dotfiles/src/utils" | ||
"github.com/spf13/cobra" | ||
"github.com/vbauerster/mpb/v7" | ||
) | ||
|
||
var UninstallEmacsCmd = &cobra.Command{ | ||
Use: "emacs", | ||
Short: "Uninstall emacs files", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
p := mpb.New() | ||
|
||
verbose, _ := cmd.Flags().GetBool("verbose") | ||
uninstallApp, _ := cmd.Flags().GetBool("uninstall-app") | ||
|
||
if !emacsInstalled() { | ||
utils.SkipMessage("Emacs is not installed") | ||
return | ||
} | ||
|
||
uninstallBar := utils.NewBar("Uninstalling emacs", 1, p) | ||
|
||
if uninstallApp { | ||
if err := utils.ExecuteCommand(verbose, "brew", "uninstall", "emacs"); err != nil { | ||
utils.ErrorMessage("Error uninstalling emacs", err) | ||
} | ||
uninstallBar.Increment() | ||
} | ||
|
||
removeFilesBar := utils.NewBar("Removing emacs files", 1, p) | ||
if err := utils.ExecuteCommand(verbose, "rm", "-rf", config.EmacsConfigDir()); err != nil { | ||
utils.ErrorMessage("Error removing emacs files", err) | ||
} | ||
removeFilesBar.Increment() | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package emacs | ||
|
||
import ( | ||
"path" | ||
|
||
"github.com/pablobfonseca/dotfiles/src/utils" | ||
) | ||
|
||
func emacsInstalled() bool { | ||
return utils.DirExists(path.Join("/Applications", "Emacs.app")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package homebrew | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/pablobfonseca/dotfiles/src/utils" | ||
"github.com/spf13/cobra" | ||
"github.com/vbauerster/mpb/v7" | ||
) | ||
|
||
var InstallHomebrewCmd = &cobra.Command{ | ||
Use: "homebrew", | ||
Short: "Install homebrew", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
p := mpb.New() | ||
verbose, _ := cmd.Flags().GetBool("verbose") | ||
bar := utils.NewBar("Installing homebrew", 1, p) | ||
|
||
if err := utils.ExecuteCommand(verbose, "/bin/bash", "-c", "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"); err != nil { | ||
fmt.Println("Error installing homebrew:", err) | ||
return | ||
} | ||
bar.Increment() | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package vim | ||
|
||
import ( | ||
"github.com/pablobfonseca/dotfiles/src/config" | ||
"github.com/pablobfonseca/dotfiles/src/utils" | ||
"github.com/spf13/cobra" | ||
"github.com/vbauerster/mpb/v7" | ||
) | ||
|
||
var UninstallVimCmd = &cobra.Command{ | ||
Use: "vim", | ||
Short: "Uninstall vim files", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
p := mpb.New() | ||
|
||
verbose, _ := cmd.Flags().GetBool("verbose") | ||
uninstallApp, _ := cmd.Flags().GetBool("uninstall-app") | ||
|
||
if !utils.CommandExists("nvim") { | ||
utils.SkipMessage("nvim is not installed") | ||
return | ||
} | ||
|
||
if uninstallApp { | ||
uninstallBar := utils.NewBar("Uninstalling nvim", 1, p) | ||
|
||
if err := utils.ExecuteCommand(verbose, "brew", "uninstall", "neovim"); err != nil { | ||
utils.ErrorMessage("Error uninstalling nvim", err) | ||
} | ||
uninstallBar.Increment() | ||
} | ||
|
||
removeFilesBar := utils.NewBar("Removing nvim files", 1, p) | ||
if err := utils.ExecuteCommand(verbose, "rm", "-rf", config.NvimConfigDir()); err != nil { | ||
utils.ErrorMessage("Error removing nvim files", err) | ||
} | ||
removeFilesBar.Increment() | ||
}, | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.