Skip to content

Instantly share code, notes, and snippets.

@tusharhqq
Last active December 8, 2025 03:02
Show Gist options
  • Select an option

  • Save tusharhqq/2f5cc5673d2b8187fff017da9085a2bb to your computer and use it in GitHub Desktop.

Select an option

Save tusharhqq/2f5cc5673d2b8187fff017da9085a2bb to your computer and use it in GitHub Desktop.
list of super cool mac terminal tricks

u-never-knew-this-mac-trick

  1. say then whatever u want ur mac to say, Siri will say whatever u want her/him to say, but don't know why it's always a male voice i tried to change it but was unable to, If someone knows how to make a female voice say in terminal
  2. security find-generic-password -wa "whatever is ur wifi name" this will show the password of the wifi stored in ur mac
  3. some command | pbcopy whatever is the output of the command will be copied to the clipboard
  4. shift command option v to copy without formatting, It's really a godsend if try to copy something from notes to Google Docs or majorly anything to Google Docs
  5. caffeinate type thing in the terminal and your Mac won't sleep till u end this command, perfect for a coffee break
  6. command control shift 4 like normally u take screenshots by pressing shift command 3 or for a specific area shift comand 4 but by doing so the screenshot will get saved on the desktop and then u have to go to the desktop and from there u need to copy and then paste it somewhere but with this command, u can take a screenshot of a particular place and copy it to clipboard.. really amazing one A couple of terminal commands to make changes around your screenshot
  7. defaults write com.apple.screencapture name -> Set a default name to your screenshots
  8. defaults write com.apple.screencapture type -> u can set your screenshot file format to jpg, png, etc
  9. default write com.apple.screencapture location ~/Desktop/screenshots Currently the default saving location for your screenshots is your desktop, u can change it with this command
  10. passwd to change your password
  11. whoami will tell u ur user name
  12. ditto there r two commands on Mac to copy and paste via your terminal, cp and ditto, don't know sure, but a Mac expert said to me that ditto is better than cp
  13. df -h will tell u how much space u have in your Mac, its full form displays free disk space
  14. man to open the manual or if u want a manual of something, like say cp command u can type, man cp
  15. open to just open things like open . will open finder, or open myprofilepic.png
  16. ping to check whether a website is up or not, like ping google.com
  17. ifconfig configures network interface parameters, u can use it with different variations and combinations as such, ifconfig en0, ifconfig en0 | grep inet, ifconfig en0 | grep inet | awk 'carry regular expressions'
  18. traceroute website.com to see the path u r taking to get to a certain website, great for troubleshooting
  19. dig websitename.com If u want to dig into DNS of a website, u can get all the DNS goodness
  20. ps to see all the processes on your computer
  21. ps -ax to see more, like a lot more
  22. top u can see which processes are using the most CPU in real-time
  23. top -o rsize can see processes by memory
  24. kill -9 processid will kill a running process, cooler combination for this is, ps -ax | grep processname
  25. which $SHELL to see which shell we r using
  26. bash to switch to bash shell
  27. zsh to switch back to zsh shell
  28. uptime to find how long have your mac been up
  29. qlmanage -p thefileNameThatUWantToPreview to preview any file
  30. diff file1 file2 to compare two files
  31. curl theLink < where u want to store to download
  32. leave 1245 will set an alarm in the terminal, and will tell u to leave at that time
  33. history to see the history of all the commands u have been typing in your terminal
  34. python3 -m http.server This will create a web server of your hard disk and anyone can go to the ip address and see your files
  35. shutdown -h now to shutdown immediately
  36. shutdown -r now to restart immediately
@marcuszhang-html
Copy link
Copy Markdown

cool

@tusharhqq
Copy link
Copy Markdown
Author

tusharhqq commented Oct 7, 2024 via email

@EmblemWu
Copy link
Copy Markdown

That python local server command impressed me, what a useful trick! Good job Tushar!

@tusharhqq
Copy link
Copy Markdown
Author

local promptnormal="φ %{$reset_color%}"

@tusharhqq
Copy link
Copy Markdown
Author

#zmodload zsh/zprof
##########
# HISTORY
##########

HISTFILE=$HOME/.zsh_history
HISTSIZE=50000
SAVEHIST=50000

setopt INC_APPEND_HISTORY     # Immediately append to history file.
setopt EXTENDED_HISTORY       # Record timestamp in history.
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
setopt HIST_IGNORE_DUPS       # Dont record an entry that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS   # Delete old recorded entry if new entry is a duplicate.
setopt HIST_FIND_NO_DUPS      # Do not display a line previously found.
setopt HIST_IGNORE_SPACE      # Dont record an entry starting with a space.
setopt HIST_SAVE_NO_DUPS      # Dont write duplicate entries in the history file.
setopt SHARE_HISTORY          # Share history between all sessions.
unsetopt HIST_VERIFY          # Execute commands using history (e.g.: using !$) immediately

#############
# COMPLETION
#############

# Add completions installed through Homebrew packages
# See: https://docs.brew.sh/Shell-Completion
if type brew &>/dev/null; then
  FPATH=/usr/local/share/zsh/site-functions:$FPATH
fi

# Speed up completion init, see: https://gist.github.com/ctechols/ca1035271ad134841284
autoload -Uz compinit
for dump in ~/.zcompdump(N.mh+24); do
  compinit
done
compinit -C

# unsetopt menucomplete
unsetopt flowcontrol
setopt auto_menu
setopt complete_in_word
setopt always_to_end
setopt auto_pushd

zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'

###############
# KEY BINDINGS
###############

# Vim Keybindings
bindkey -v

# This is a "fix" for zsh in Ghostty:
# Ghostty implements the fixterms specification https://www.leonerd.org.uk/hacks/fixterms/
# and under that `Ctrl-[` doesn't send escape but `ESC [91;5u`.
#
# (tmux and Neovim both handle 91;5u correctly, but raw zsh inside Ghostty doesn't)
#
# Thanks to @rockorager for this!
bindkey "^[[91;5u" vi-cmd-mode

# Open line in Vim by pressing 'v' in Command-Mode
autoload -U edit-command-line
zle -N edit-command-line
bindkey -M vicmd v edit-command-line

# Push current line to buffer stack, return to PS1
bindkey "^Q" push-input

# Make up/down arrow put the cursor at the end of the line
# instead of using the vi-mode mappings for these keys
bindkey "\eOA" up-line-or-history
bindkey "\eOB" down-line-or-history
bindkey "\eOC" forward-char
bindkey "\eOD" backward-char

# CTRL-R to search through history
bindkey '^R' history-incremental-search-backward
# CTRL-S to search forward in history
bindkey '^S' history-incremental-search-forward
# Accept the presented search result
bindkey '^Y' accept-search

# Use the arrow keys to search forward/backward through the history,
# using the first word of what's typed in as search word
bindkey '^[[A' history-search-backward
bindkey '^[[B' history-search-forward

# Use the same keys as bash for history forward/backward: Ctrl+N/Ctrl+P
bindkey '^P' history-search-backward
bindkey '^N' history-search-forward

# Backspace working the way it should
bindkey '^?' backward-delete-char
bindkey '^[[3~' delete-char

# Some emacs keybindings won't hurt nobody
bindkey '^A' beginning-of-line
bindkey '^E' end-of-line

# Where should I put you?
bindkey -s '^F' "tmux-sessionizer\n"

#########
# Aliases
#########

case $OSTYPE in
 darwin*)
    local aliasfile="${HOME}/.zsh.d/aliases.Darwin.sh"
    [[ -e ${aliasfile} ]] && source ${aliasfile}
  ;;
esac

if type lsd &> /dev/null; then
  alias ls=lsd
fi
alias lls='ls -lh --sort=size --reverse'
alias llt='ls -lrt'
alias bear='clear && echo "Clear as a bear!"'

alias history='history 1'
alias hs='history | grep '

# Use rsync with ssh and show progress
alias rsyncssh='rsync -Pr --rsh=ssh'

# Edit/Source nvim config
alias ez='vi ~/.zshrc'
alias sz='source ~/.zshrc'

#fzf 
alias ea='nvim $(fzf --preview="cat {}")'
#alias fkf ='nvim $(fzf --preview="cat {}")'
#vi $(fzf --preview='cat {}')
#nvim $(fzf --preview='cat {}')

# git
alias gst='git status'
alias gaa='git add -A'
alias gc='git commit'
alias gcm='git checkout trunk'
alias gd='git diff'
alias gdc='git diff --cached'
# [c]heck [o]ut
alias co='git checkout'
# [f]uzzy check[o]ut
fo() {
  git branch --no-color --sort=-committerdate --format='%(refname:short)' | fzf --header 'git checkout' | xargs git checkout
}
# [p]ull request check[o]ut
po() {
  gh pr list --author "@me" | fzf --header 'checkout PR' | awk '{print $(NF-5)}' | xargs git checkout
}
alias up='git push'
alias upf='git push --force'
alias pu='git pull'
alias pur='git pull --rebase'
alias fe='git fetch'
alias re='git rebase'
alias lr='git l -30'
alias cdr='cd $(git rev-parse --show-toplevel)' # cd to git Root
alias hs='git rev-parse --short HEAD'
alias hm='git log --format=%B -n 1 HEAD'

# tmux
alias tma='tmux attach -t'
alias tmn='tmux new -s'
alias tmm='tmux new -s main'
# ceedee dot dot dot
alias -g ...='../..'
alias -g ....='../../..'
alias -g .....='../../../..'

# Go
alias got='go test ./...'

alias k='kubectl'

alias -g withcolors="| sed '/PASS/s//$(printf "\033[32mPASS\033[0m")/' | sed '/FAIL/s//$(printf "\033[31mFAIL\033[0m")/'"

alias zedn='/Applications/Zed\ Nightly.app/Contents/MacOS/cli'
alias r='cargo run'
alias rr='cargo run --release'

##########
# FUNCTIONS
##########

mkdircd() {
    mkdir -p $1 && cd $1
}

spinner() {
    while
    do
        for i in "-" "\\" "|" "/"
        do
            echo -n " $i \r\r"
            sleep .1
        done
    done
}

# Open PR on GitHub
pr() {
  if type gh &> /dev/null; then
    gh pr view -w
  else
    echo "gh is not installed"
  fi
}


#########
# PROMPT
#########

setopt prompt_subst

git_prompt_info() {
  local dirstatus=" OK"
  local dirty="%{$fg_bold[red]%} X%{$reset_color%}"

  if [[ ! -z $(git status --porcelain 2> /dev/null | tail -n1) ]]; then
    dirstatus=$dirty
  fi

  ref=$(git symbolic-ref HEAD 2> /dev/null) || \
  ref=$(git rev-parse --short HEAD 2> /dev/null) || return
  echo " %{$fg_bold[green]%}${ref#refs/heads/}$dirstatus%{$reset_color%}"
}

# local dir_info_color="$fg_bold[black]"

# This just sets the color to "bold".
# Future me. Try this to see what's correct:
#   $ print -P '%fg_bold[black] black'
#   $ print -P '%B%F{black} black'
#   $ print -P '%B black'
local dir_info_color="%B"

local dir_info_color_file="${HOME}/.zsh.d/dir_info_color"
if [ -r ${dir_info_color_file} ]; then
  source ${dir_info_color_file}
fi

local dir_info="%{$dir_info_color%}%(5~|%-1~/.../%2~|%4~)%{$reset_color%}"
local promptnormal="φ %{$reset_color%}"
local promptjobs="%{$fg_bold[red]%}φ %{$reset_color%}"



simple_prompt() {
  local prompt_color="%B"
  export PROMPT="%{$prompt_color%}$promptnormal"
}

#########
# PROMPT
#########

setopt prompt_subst

git_prompt_info() {
  local dirstatus=" OK"
  local dirty="%{$fg_bold[red]%} X%{$reset_color%}"

  if [[ ! -z $(git status --porcelain 2> /dev/null | tail -n1) ]]; then
    dirstatus=$dirty
  fi

  ref=$(git symbolic-ref HEAD 2> /dev/null) || \
  ref=$(git rev-parse --short HEAD 2> /dev/null) || return
  echo " %{$fg_bold[green]%}${ref#refs/heads/}$dirstatus%{$reset_color%}"
}

# local dir_info_color="$fg_bold[black]"

# This just sets the color to "bold".
# Future me. Try this to see what's correct:
#   $ print -P '%fg_bold[black] black'
#   $ print -P '%B%F{black} black'
#   $ print -P '%B black'
local dir_info_color="%B"

local dir_info_color_file="${HOME}/.zsh.d/dir_info_color"
if [ -r ${dir_info_color_file} ]; then
  source ${dir_info_color_file}
fi

local dir_info="%{$dir_info_color%}%(5~|%-1~/.../%2~|%4~)%{$reset_color%}"
local promptnormal="φ %{$reset_color%}"
local promptjobs="%{$fg_bold[red]%}φ %{$reset_color%}"



simple_prompt() {
  local prompt_color="%B"
  export PROMPT="%{$prompt_color%}$promptnormal"
}

########
# ENV
########

export COLOR_PROFILE="dark"

case $OSTYPE in
 darwin*)
    local envfile="${HOME}/.zsh.d/env.Darwin.sh"
    [[ -e ${envfile} ]] && source ${envfile}
  ;;
esac

export LSCOLORS="Gxfxcxdxbxegedabagacad"

# Reduce delay for key combinations in order to change to vi mode faster
# See: http://www.johnhawthorn.com/2012/09/vi-escape-delays/
# Set it to 10ms
export KEYTIMEOUT=1

export PATH="$HOME/neovim/bin:$PATH"

if type nvim &> /dev/null; then
  alias vi="nvim"
  export EDITOR="nvim"
  export PSQL_EDITOR="nvim -c"set filetype=sql""
  export GIT_EDITOR="nvim"
else
  export EDITOR='vi'
  export PSQL_EDITOR='vi -c"set filetype=sql"'
  export GIT_EDITOR='vi'
fi

if [[ -e "$HOME/code/clones/lua-language-server/3rd/luamake/luamake" ]]; then
  alias luamake="$HOME/code/clones/lua-language-server/3rd/luamake/luamake"
fi

# fzf
if type fzf &> /dev/null && type rg &> /dev/null; then
  export FZF_DEFAULT_COMMAND='rg --files --hidden --follow --glob "!.git/*" --glob "!vendor/*"'
  export FZF_CTRL_T_COMMAND='rg --files --hidden --follow --glob "!.git/*" --glob "!vendor/*"'
  export FZF_ALT_C_COMMAND="$FZF_DEFAULT_COMMAND"
fi

# direnv
if type direnv &> /dev/null; then
  eval "$(direnv hook zsh)"
fi








export PATH=$PATH:/Users/blouse_man/go/bin

alias vi="nvim"

# bun completions
[ -s "/Users/blouse_man/.bun/_bun" ] && source "/Users/blouse_man/.bun/_bun"

# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"

[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
PQ_LIB_DIR="$(brew --prefix libpq)/lib"

# Generated for envman. Do not edit.
[ -s "$HOME/.config/envman/load.sh" ] && source "$HOME/.config/envman/load.sh"


#export JAVA_HOME=$(/usr/libexec/java_home)
#export PATH=$JAVA_HOME/bin:$PATH

export JAVA_HOME=$(/usr/libexec/java_home -v 17)
#export JAVA_HOME=$(/usr/libexec/java_home -v 11)
#export JAVA_HOME=$(/usr/libexec/java_home -v 22)
export PATH=$JAVA_HOME/bin:$PATH

export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH


# pnpm
export PNPM_HOME="/Users/blouse_man/Library/pnpm"
case ":$PATH:" in
  *":$PNPM_HOME:"*) ;;
  *) export PATH="$PNPM_HOME:$PATH" ;;
esac
# pnpm end
#
#
export PATH=$PATH:/opt/homebrew/bin






#zprof



# BEGIN opam configuration
# This is useful if you're using opam as it adds:
#   - the correct directories to the PATH
#   - auto-completion for the opam binary
# This section can be safely removed at any time if needed.
[[ ! -r '/Users/blouse_man/.opam/opam-init/init.zsh' ]] || source '/Users/blouse_man/.opam/opam-init/init.zsh' > /dev/null 2> /dev/null
# END opam configuration

source <(fzf --zsh)
export GPG_TTY=$(tty) # or /Users/blouse_man/.bashrc if you use bash

# Added by Windsurf
export PATH="/Users/blouse_man/.codeium/windsurf/bin:$PATH"
export PATH="/opt/homebrew/opt/lua@5.1/bin:$PATH"
export PATH="/opt/homebrew/Cellar/sevenzip/24.09/bin:$PATH"

# Cursor
alias c="open $1 -a \"Cursor\""
# Visual Studio Code
alias v="open $1 -a \"Visual Studio Code\""
eval "$(rbenv init - --no-rehash zsh)"


@tusharhqq
Copy link
Copy Markdown
Author

--require("supermaven-nvim").setup({
-- keymaps = {
-- accept_suggestion = "",
-- clear_suggestion = "<C-]>",
-- accept_word = "",
-- },
-- ignore_filetypes = { cpp = true }, -- or { "cpp", }
-- color = {
-- suggestion_color = "#ffffff",
-- cterm = 244,
-- },
-- log_level = "info", -- set to "off" to disable logging completely
-- disable_inline_completion = false, -- disables inline completion for use with cmp
-- disable_keymaps = false, -- disables built in keymaps for more manual control
-- condition = function()
-- return false
-- end -- condition to check for stopping supermaven, true means to stop supermaven when the condition is true.
-- })

@HugoCodesig
Copy link
Copy Markdown

HugoCodesig commented Jul 12, 2025

this is great! so many things i didn't know were possible. this impressed me tbh
that python3 http.server command is kinda dangerous tho, i tried and it lists EVERY SINGLE ONE of your files, even hidden ones. kinda scary
the wifi password one was kinda cool tho, i made an alias to make it easier to type. add on your .zshrc:

function wifipass
{
  command security find-generic-password -wa $1
}

anyways, i appreciate this info! really cool things.

@tusharhqq
Copy link
Copy Markdown
Author

tusharhqq commented Jul 12, 2025 via email

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