Series: oh-my-zsh
Part 3/4Hello! 😊
What is the shopt command? The shopt command allows you to change some actions within bash (shell). In a way, it serves a similar function to the alias command. Now let's explain with an example.
When you enter a directory with cd directory command, with the shopt command you can add to your bashrc file and directly write the directory name to enter that directory. Of course, the usage areas of the shopt command are not limited to these. For more information, you can visit Details.
Usage Within Zsh#
Since Shopt works bash-based, you will naturally get a 'shopt command not found' error in zsh bash. The solution to this is quite simple.
Solution#
First, enter the following command in your terminal:
touch shopt
Then update the file you created with the following code:
#!/bin/bash
args='';
for item in $@
do
args="$args $item";
done
shopt $args;
Afterwards, move this file to the system with the following command:
sudo mv shopt /usr/bin/
Finally, add the following command to your .zshrc file:
alias shopt='/usr/bin/shopt'
That's it! Now you can use the shopt command smoothly within Zsh. Enjoy! 😄
Additional Information#
When backing up, it's very important not to forget the scripts you created. Especially during system migrations, I sometimes forget. 🤣
If you don't want to forget your scripts, you can use the Auto Script Generator.
alias shopt='ScriptDirectory/shopt'
Resource Used: larz258
You can test the following shopt settings by adding them to your .zshrc or .bashrc file:
#bash opts
shopt -s autocd
shopt -s cdspell
shopt -s cmdhist
shopt -s histappend
shopt -s expand_aliases
shopt -s checkwinsize
shopt -s globstar 2> /dev/null
shopt -s nocaseglob
shopt -s autocd 2> /dev/null
shopt -s dirspell 2> /dev/null
shopt -s cdspell 2> /dev/null
My Zsh Settings! + Script Generator!

Comments