Created
August 19, 2025 17:49
-
-
Save bmorrisondev/411dae206f8ab265d2d805a50089425f to your computer and use it in GitHub Desktop.
My custom terminal rc file (sourced from ~/.zshrc)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ========================================== | |
| # CLI Tools Configuration | |
| # ========================================== | |
| # Aliases for better tools | |
| alias ls='eza --color=always --group-directories-first -l' | |
| alias ll='eza -alF --color=always --group-directories-first' | |
| alias la='eza -al --color=always --group-directories-first' | |
| alias l='eza -Fl --color=always --group-directories-first' | |
| alias l.='eza -a | grep "^\."' | |
| alias lt='eza -aT --color=always --group-directories-first' | |
| # Use bat instead of cat | |
| alias cat='bat' | |
| alias catp='bat --style=plain' # Plain style for scripts | |
| alias jcat='jq . < $_1 | bat -l json' # Use jq to prettify and parse json into bat | |
| # Use ripgrep instead of grep | |
| alias grep='rg' | |
| # Better find | |
| alias find='fd' | |
| # Git aliases with delta integration | |
| alias gd='git diff' | |
| alias gl='git log --oneline --graph --decorate' | |
| alias gs='git status' | |
| # FZF configuration | |
| export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git' | |
| export FZF_DEFAULT_OPTS=' | |
| --height 40% | |
| --layout=reverse | |
| --border | |
| --preview "bat --style=numbers --color=always --line-range :500 {}" | |
| --preview-window right:50%:wrap | |
| --bind "ctrl-y:execute-silent(echo {} | pbcopy)" | |
| --bind "ctrl-o:execute(code {})" | |
| --color=fg:#f8f8f2,bg:#282a36,hl:#bd93f9 | |
| --color=fg+:#f8f8f2,bg+:#44475a,hl+:#bd93f9 | |
| --color=info:#ffb86c,prompt:#50fa7b,pointer:#ff79c6 | |
| --color=marker:#ff79c6,spinner:#ffb86c,header:#6272a4' | |
| # Ctrl+T - file search | |
| export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" | |
| export FZF_CTRL_T_OPTS=" | |
| --preview 'bat --style=numbers --color=always --line-range :500 {}' | |
| --preview-window right:50%:wrap | |
| " | |
| # Alt+C - directory search | |
| export FZF_ALT_C_COMMAND='fd --type d --hidden --follow --exclude .git' | |
| export FZF_ALT_C_OPTS=" | |
| --preview 'tree -C {} | head -200' | |
| --preview-window right:50%:wrap | |
| " | |
| # Ctrl+R - command history | |
| export FZF_CTRL_R_OPTS=" | |
| --preview 'echo {}' | |
| --preview-window up:3:hidden:wrap | |
| --bind 'ctrl-y:execute-silent(echo -n {2..} | pbcopy)+abort' | |
| --color header:italic | |
| --header 'Press CTRL-Y to copy command into clipboard' | |
| " | |
| # FZF key bindings and completion | |
| [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh | |
| # Git integration with FZF | |
| # Ctrl+G+F to search files in git repo | |
| # Ctrl+G+B to search branches | |
| # Ctrl+G+L to search commit history | |
| bind-git-helper() { | |
| local char | |
| stty -echo | |
| char=$(dd bs=1 count=1 2>/dev/null) | |
| stty echo | |
| if [[ $char == "f" ]]; then | |
| # Search files | |
| git ls-files | fzf --preview 'bat --color=always {}' | |
| elif [[ $char == "b" ]]; then | |
| # Search branches | |
| git branch -a | fzf | sed 's/^..//' | sed 's/remotes\/origin\///' | |
| elif [[ $char == "l" ]]; then | |
| # Search commit history | |
| git log --oneline | fzf --preview 'git show --color=always {1}' | |
| fi | |
| } | |
| bindkey '^g' bind-git-helper | |
| # Delta configuration for git | |
| export GIT_PAGER="delta" | |
| # Bat configuration | |
| export BAT_THEME="TwoDark" | |
| export BAT_PAGER="less -RF" | |
| # Better history search with fzf | |
| bindkey '^r' fzf-history-widget | |
| # Functions for common tasks | |
| # Search and edit files | |
| fe() { | |
| local files | |
| IFS=$'\n' files=($(fzf --query="$1" --multi --select-1 --exit-0)) | |
| [[ -n "$files" ]] && ${EDITOR:-vim} "${files[@]}" | |
| } | |
| # Search and open files or directories in neovim | |
| nvf() { | |
| local files | |
| IFS=$'\n' files=($(fd --hidden --follow --exclude .git | fzf --query="$1" --multi --select-1 --exit-0)) | |
| [[ -n "$files" ]] && nvim "${files[@]}" | |
| } | |
| # Kill processes with fzf | |
| fkill() { | |
| local pid | |
| pid=$(ps -ef | sed 1d | fzf -m | awk '{print $2}') | |
| if [ "x$pid" != "x" ]; then | |
| echo $pid | xargs kill -${1:-9} | |
| fi | |
| } | |
| # CD to directory with fzf | |
| fcd() { | |
| local dir | |
| dir=$(fd --type d | fzf +m) && cd "$dir" | |
| } | |
| # Search in command history | |
| fh() { | |
| print -z $( ([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac | sed 's/ *[0-9]* *//') | |
| } | |
| # Additional FZF convenience aliases and functions | |
| # Interactive git checkout | |
| alias gcb='git branch | fzf | xargs git checkout' | |
| # Kill process with fzf (alternative implementation) | |
| alias fkillalt='ps aux | fzf | awk "{print \$2}" | xargs kill -9' | |
| # CD to directory with preview (enhanced version) | |
| fcde() { | |
| local dir | |
| dir=$(fd --type d --hidden --follow --exclude .git | fzf --preview 'tree -C {} | head -200') && | |
| cd "$dir" | |
| } | |
| # GitHub CLI shortcuts | |
| alias ghpr='gh pr create --title' | |
| alias ghprs='gh pr status' | |
| alias ghrepo='gh repo view --web' | |
| # Tree with better defaults | |
| alias tree='tree -a -I ".git|node_modules|.DS_Store"' | |
| # Dust (disk usage) with better defaults | |
| alias du='dust' | |
| # HTTP shortcuts | |
| alias GET='http GET' | |
| alias POST='http POST' | |
| alias PUT='http PUT' | |
| alias DELETE='http DELETE' | |
| # Initialize git repo and create GitHub repository | |
| ghinit() { | |
| local current_dir=$(basename "$PWD") | |
| # Check if we're already in a git repository | |
| if ! git rev-parse --git-dir > /dev/null 2>&1; then | |
| echo "Initializing git repository..." | |
| git init | |
| else | |
| echo "Already in a git repository." | |
| fi | |
| # Create GitHub repository with the same name as current directory | |
| echo "Creating GitHub repository: $current_dir" | |
| if ! gh repo create "$current_dir" --public --source=. --remote=origin --push; then | |
| echo "Failed to create GitHub repository. Continuing with local setup..." | |
| return 1 | |
| fi | |
| # Add all files to git | |
| echo "Adding all files to git..." | |
| git add . | |
| # Create initial commit if there are changes to commit | |
| if ! git diff --cached --quiet; then | |
| echo "Creating initial commit..." | |
| git commit -m "initial commit" | |
| # Push to remote (this might already be done by gh repo create --push) | |
| echo "Pushing to remote..." | |
| git push -u origin main 2>/dev/null || git push -u origin master 2>/dev/null | |
| echo "✅ Repository initialized and pushed to GitHub successfully!" | |
| else | |
| echo "No changes to commit." | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment