Search code examples
shellzshzshrc

How can I echo a shell command as a string


I want place the following string into my .zshrc file using the command line

eval "$(docker exec -it <abc-123>)"

I've tried:

echo "eval "$(docker exec -it <abc-123>)"" >> .zshrc

and every other ` and ' combination

The result I want is to have my .zshrc file execute eval "$(docker exec -it <abc-123>)" much like it does for homebrew eval "$(/opt/homebrew/bin/brew shellenv)"

I just want to be able to write to my .zshrc file using echo. How can I achieve this?


Solution

  • echo 'eval "$(docker exec -it <abc-123>)"' >> .zshrc
    

    Will add

    eval "$(docker exec -it <abc-123>)"
    

    at the end of your .zshrc file