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

alias adjust again #10

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
9 changes: 6 additions & 3 deletions subcommands/alias_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ 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")
home, err := os.UserHomeDir()

if err != nil {
return nil
}

path := home + "/.bash_aliases"

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

Expand All @@ -42,12 +43,14 @@ func AddAliasUnix(name string, ed string) error {
func RemoveAliasUnix(name string, ed string) error {

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

if err != nil {
return nil
}

path := home + "/.bash_aliases"

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

Expand Down