I am aware that in Linux I can use the alias
command to get a list of defined aliases. I am now trying to do the same through Go code with:
func ListAlias() error {
out, err := exec.Command("alias").Output()
if err != nil {
fmt.Println(err)
return err
}
fmt.Println(out)
return nil
}
but all that were returned were:
exec: "alias": executable file not found in $PATH
I tried looking for where the actual binary of alias
is but that leads nowhere either:
$whereis alias
alias:
The alternative I've considered is to parse the ~/.bashrc
file for the list of aliases defined but I have encountered this scenario where the bashrc
lists another custom_aliases.sh
file and all the aliases are listed there. That's why I am trying to use the alias
command to list all the aliases.