This script gamifies your terminal by tracking experience points and levels based on the number of commands you execute. Newly found commands give more EXP, repeated commands give less, and even incorrect commands still grant a small amount—at least you tried. Contains 14 unlockable ranks and 78 achievements. Supports bash and zsh shells.
- Save this file in your home directory:
curl --output ~/gamifier "https://raw.githubusercontent.com/Divinux/linux-terminal-gamifier/refs/heads/main/gamifier"
- Source the file in your
.bashrc. This can be done manually or by running:echo 'source ~/gamifier' >> ~/.bashrc
- Ensure your history is reloaded after each command, then call
update_exp. If you have not yet modified yourPROMPT_COMMAND, you can simply run:echo 'export PROMPT_COMMAND="history -a; history -n; update_exp; $PROMPT_COMMAND"' >> ~/.bashrc
- Restart your terminal or run:
source ~/.bashrc
- Save this file in your home directory:
curl --output ~/gamifier "https://raw.githubusercontent.com/Divinux/linux-terminal-gamifier/refs/heads/main/gamifier"
- Source the file in your
.zshrc. This can be done manually or by running:echo 'source ~/gamifier' >> ~/.zshrc
- Ensure your history is reloaded after each command, then call
update_exp. If you have not yet modified yourprecmdhook, you can simply run:echo -e "setopt incappendhistory\nprecmd() { update_exp; }" >> ~/.zshrc
- Restart your terminal or run:
source ~/.zshrc
- This script creates a directory under
$XDG_DATA_HOME(defaults to~/.local/share/if$XDG_DATA_HOMEis not set) with four additional files:.exp: Tracks the current experience amount and level..usedcommands: Contains all commands the user has used so far..achievements: Tracks the status of all achievements..streak: tracks the daily use streak.
- To continue tracking your progress on a new install, just copy this directory over.
- You may want to increase your
HISTSIZEandHISTFILESIZE.- Setting them to nothing, i.e.,
HISTSIZE=andHISTFILESIZE=, makes them unlimited.
- Setting them to nothing, i.e.,
- Use
checkrankat any time to check your current progress. - Use
checkstatsto display usage stats. - Use
ghelpto display a short info message. - Use
gupdateto update Linux Terminal Gamifier. - Use
gimportto (re)import the history file. - Found to work well with bashcrawl, a terminal commands learning adventure game.
- Once the "New command discovered!" messages lose their novelty, they can be disabled by setting the notify_on_new variable in line 65 to false.
- Security consideration: The script pulls straight from your history file and saves to the .usedcommands file, so it will not contain anything that your history does not already contain anyways, just be aware that there is now a copy of your history saved somewhere else.
Q: The script stops working after installing OhMy*
A: OhMy* overwrites the PROMPT_COMMAND, so either make sure to install OhMy* before the Gamifier script, or add update_exp to your PROMPT_COMMAND manually afterwards.
Q: The script doesn't notice me changing settings in it or in my .bashrc/.zshrc
A: Sometimes just calling source .bashrc or source .zshrc isn't enough, refreshing the script explicitly with source gamifier usually solves this issue.
- Remove
source ~/gamifierandupdate_exp;from your.bashrcfor bash or
Removesource ~/gamifier,setopt incappendhistory, andprecmd() { update_exp; }from your.zshrcfor zsh. - Delete the
gamifierfile to remove the script. - Delete the
~/.local/share/gamifierdirectory to remove your savefiles. - Restart your terminal.
