Correct me if I'm wrong. You want to have the ll alias available inside the container.
You can achieve this by:
- Adding this to the Dockerfile:
RUN echo "alias ll='ls -alF'" >> /etc/bash.bashrc
If you want to leave the Dockerfile as is:
Use the postCreateCommand from vscode (If you don't want to change the dockerfile):
"postCreateCommand": "echo alias ll=\\'ls -alF\\' >> /etc/bash.bashrc"This will add the alias directly to the system-wide bashrc file. The alias will be available in all interactive shells started within the container.OR
"postCreateCommand": "echo alias ll=\\'ls -alF\\' >> ~/.bash_aliases"This adds the alias to a separate file specifically for aliases and doesn't require root access in the container. Be aware: You'll need to source the .bash_aliases in .bashrc or else this won't work.(credit: @user317808)
If you run into a "Permission denied" then you can also do this:
"postCreateCommand": "echo alias ll=\\'ls -alF\\' >> /home/vscode/.bashrc" (credit: @Damian)
Correct me if I'm wrong. You want to have the ll alias available inside the container.
You can achieve this by:
- Adding this to the Dockerfile:
RUN echo "alias ll='ls -alF'" >> /etc/bash.bashrc
If you want to leave the Dockerfile as is:
Use the postCreateCommand from vscode (If you don't want to change the dockerfile):
"postCreateCommand": "echo alias ll=\\'ls -alF\\' >> /etc/bash.bashrc"This will add the alias directly to the system-wide bashrc file. The alias will be available in all interactive shells started within the container.OR
"postCreateCommand": "echo alias ll=\\'ls -alF\\' >> ~/.bash_aliases"This adds the alias to a separate file specifically for aliases and doesn't require root access in the container. Be aware: You'll need to source the .bash_aliases in .bashrc or else this won't work.(credit: @user317808)
If you run into a "Permission denied" then you can also do this:
"postCreateCommand": "echo alias ll=\\'ls -alF\\' >> /home/vscode/.bashrc" (credit: @Damian)
If you are using Dockerfile as part of your devcontainer setup you could have a file called devcontainer.bashrc that you move into the home folder in your Dockerfile:
...
USER vscode
COPY devcontainer.bashrc /home/vscode/.bashrc
...
and your devcontainer.bashrc
alias ll="ls -l"
alias la="ls -a"
and avoid writing long commands in your "postCreateCommand" which is harder to debug/modify as it gets long
Edit: in reply to comment: If you don't want to create a Dockerfile and are using the pure devcontainer.json approach, you could do:
{
"postCreateCommand": "cp ${containerWorkspaceFolder}/devcontainer.bashrc /home/vscode/.bashrc
}