I'm tired of writing all kubectl and kubeadm commands by hand. Is there any way of enabling autocomplete on these commands?
Bash Solution
# Execute these commands
$ echo "source <(kubectl completion bash)" >> ~/.bashrc
$ echo "source <(kubeadm completion bash)" >> ~/.bashrc
# Reload bash without logging out
$ source ~/.bashrc
Related
I was trying to install a plug-in "vim-surround" but it doesn't work after executing the following commands on my terminal.
$ mkdir -p ~/.vim/pack/tpope/start
$ cd ~/.vim/pack/tpope/start
$ git clone https://tpope.io/vim/surround.git
$ vim -u NONE -c "helptags surround/doc" -c q
I'm new to Vim and I was wondering if there's more to just typing those commands on the terminal? Do I have to add some lines on the config file to make it work?
Thank you in advance.
When using kubectl run -ti with an interactive terminal, I would like to be able to pass a few commands in the kubectl run command to be run before the interactive terminal comes up, commands like apt install zip for example. In this way, I do not need to wait for the interactive terminal to come up and then run those common commands. Is there a way do so this?
Thanks
You can use the shell's exec to hand control over from your initial "outer" bash, responsible for doing the initialization steps you want, over to a fresh one (fresh in the sense that it does not have -c and can optionally be a login shell) which runs after your pre-steps:
kubectl run sample -it --image=ubuntu:20.04 -- \
bash -c "apt update; apt install -y zip; exec bash -il"
Every time I open WSL Ubuntu 18.04 on Windows 10 I want to run these settings automatically.
alias desktop='cd /mnt/c/Users/Dot/Desktop/ai_files'
export PYTHONPATH=${PYTHONPATH}:${HOME}/ai-safety-gridworlds
export DISPLAY=localhost:0.0
I tried making .sh script with the following content in /etc/init.d/ but it didn't work.
#!/bin/bash
alias desktop='cd /mnt/c/Users/Dot/Desktop/ai_files'
export PYTHONPATH=${PYTHONPATH}:${HOME}/ai-safety-gridworlds
export DISPLAY=localhost:0.0
To run these commands every time you open WSL, you will want to append the commands to .bashrc.
In bash, run
echo "alias desktop='cd /mnt/c/Users/Dot/Desktop/ai_files'" >> ~/.bashrc
echo "export PYTHONPATH=${PYTHONPATH}:${HOME}/ai-safety-gridworlds" >> ~/.bashrc
echo "export DISPLAY=localhost:0.0" >> ~/.bashrc
To create an environment variable which will be visible for all users on Ubuntu you can create a sh file in /etc/profile.d folder.
In example :
sudo vi /etc/profile.d/my_vars.sh && sudo chmod o+r /etc/profile.d/my_vars.sh
then include there your variables. For example:
export ORACLE_HOME="/opt/oracle/instantclient_11_2"
terminate and start wsl again. Variables should be accessible for all users.
I am trying to truncate a file in Red Hat 4.8.5-11. I have zsh+prezto installed on my system. I am getting error:
"zsh: file exists: {file_name}"
I am running following command:
echo -n > {file_name}
Same command is running just fine in bash. What could possibly be wrong?
This is caused by the no-clobbering setting which protects you from accidently overwriting a file: http://zsh.sourceforge.net/Doc/Release/Options.html#index-file-clobbering_002c-allowing
You can either force it using the pipe character:
echo -n >| {file_name}
Or you can disable this behaviour by enabling clobbering:
setopt clobber
I'm doing a script and I would like to add the following line
pre-up iptables-restore < /etc/iptables.rules
to the file interfaces which is located on /etc/network/interfaces,but although I have enabled the permissions to write in this file(I work in Ubuntu), I'm not able to do it... I'm trying to use the following command in my bash script
sudo echo "pre-up iptables-restore < /etc/iptables.rules" >> /etc/network/interfaces
Any suggestion of how to do it without using gedit o vi?
Thanks in advance!
You need to tell bash not to use redirection before it starts sudo:
sudo bash -c 'echo "pre-up iptables-restore < /etc/iptables.rules" >> /etc/network/interfaces'
this way the complete command will be executed with root access, not only the echo "pre-up iptables-restore < /etc/iptables.rules" part