Skip to content

Instantly share code, notes, and snippets.

@kazimmsyed
Last active June 30, 2026 05:37
Show Gist options
  • Select an option

  • Save kazimmsyed/e3a852dfa53e96aed61656659545678c to your computer and use it in GitHub Desktop.

Select an option

Save kazimmsyed/e3a852dfa53e96aed61656659545678c to your computer and use it in GitHub Desktop.
How to set bindkeys aka shortcuts to bigger text of code and setting the prompt and mysql. And how the zsh enviorment variables and other are loaded into the system and for user personal use.
% cat ~/.zlogin lily Patronus Fri 6
#setting mysql
path[8]=/usr/local/mysql/bin;
#Setting shell prompt
PROMPT="%{$fg[yellow]%}%n@%m%{$reset_color%} %~"$'\n'"%# "
#setting bindkey for mysql
bindkey -s '^' "mysql -u root -p"
@kazimmsyed

kazimmsyed commented Jan 6, 2023

Copy link
Copy Markdown
Author

image

@kazimmsyed

Copy link
Copy Markdown
Author

All these hidden files resides on the $HOME

zshenv -> zprofile -> zlogin -> zshrc -> zlogout

Facts:

zshenv

Have a smaller zshenv file, so it opens quickly. Zshenv is for environment variables that ur entire file needs. So use it sparingly. Not suited for api keys. Rather use .zprofile and ".secret" files.

You can run scripts either using
source script.sh or ./scriph.sh

Shell inheritance

source creates another subshell. When a subshell is created zprofile, zlogin are skipped. This subshell is called non-login subshell because it was created by another shell, it has nothing to do about login and authentication. Since zprofile creates the shell environment, the env is inherited by the subshell, because of something known as shell inheritance. whereas, ./script.sh runs in the current shell.

Advice

Imagine a pie,
Majority party: is to keep majority of ur commands on zshrc like bindkey and environment variable setups by npm.
Competing party: is to keep the minority of setup files that is setting up environment variables in zprofile and important note is "shell environment is created in zprofile".
Other: zshenv or zlogin(optional).

@kazimmsyed

kazimmsyed commented Jun 30, 2026

Copy link
Copy Markdown
Author

% cat ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
#setting mysql
typeset -U path
`

path=( /usr/local/mysql/bin #Add your own PATH entries here #"$HOME/some/tool/bin" $path )
#Load personal secrets
[[ -f ~/.secrets ]] && source ~/.secrets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment