Buy @ Amazon

Aliases Created In Terminal Not Showing Up In Tmux

Issue

I create a few aliases in terminal like below:
alias k=kubectl
source <(kubectl completion bash)
And then I open a tmux session with command: tmux.

Now inside of tmux pane, when I try using the alias and expect the behaviour of source command run in terminal, it fails! :(

Why does this happen and how do I get it right?

The context is that I end up using multiple panes in tmux and I don't want to re-peat the same set of aliases creation again and again as I open every tmux pane. Possible?

Side Note: If you don't know this, it might be another cause for your stress during your CKA/CKAD exam.

Cause

Aliases are not inherited or passed onto newly spawned shells magically.

Recipe

Simple create a custom script file, say .myscript and source it in every new tmux pane that is opened with the command like: "source ./.myscript".