Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

alias unix change #9

Merged
merged 1 commit into from
Jun 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions subcommands/alias_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@ import (
"bufio"
"io"
"os"
"path/filepath"
)

//AddAlias will add the alias for the package name specified
func AddAliasUnix(name string, ed string) error {

//get the bash aliases file path
path, err := filepath.Abs("~/.bash_aliases")

if err != nil {
return nil
}

//If run on linux lets modify the bash aliases file to include the new aliases
file, err := os.OpenFile("~/.bash_aliases", os.O_APPEND|os.O_CREATE, 0755)
file, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE, 0755)

if err != nil {
return err
Expand All @@ -31,8 +40,16 @@ func AddAliasUnix(name string, ed string) error {

//Remove Alias will remove the alias for the specified package name from the corresponding files
func RemoveAliasUnix(name string, ed string) error {

//get the bash aliases file path
path, err := filepath.Abs("~/.bash_aliases")

if err != nil {
return nil
}

//If it isnt windows, remove it from the bash aliases file
file, err := os.OpenFile("~/.bash_aliases", os.O_RDWR, 0755)
file, err := os.OpenFile(path, os.O_RDWR, 0755)

var newOut []string

Expand Down