diff --git a/CHEATSHEET.md b/CHEATSHEET.md new file mode 100644 index 0000000..4443c29 --- /dev/null +++ b/CHEATSHEET.md @@ -0,0 +1,144 @@ +# My Terminal Cheat Sheet + +## Custom Commands + +### Search & AI +- `?` - Google search in Zen browser + - Example: `? how to use tmux` +- `??` - Claude Code query (streaming output) + - Example: `?? explain this code` +- `?? -a` - Claude Code interactive session + - Example: `?? -a help me refactor` + +## Tmux Keybindings + +### Prefix Key +- `Ctrl+Space` - Prefix key (instead of default Ctrl+b) + +### Special Popups +- `Ctrl+Space + g` - Lazygit popup (90% window) +- `Ctrl+Space + ?` - This cheat sheet popup (85% window) + +### Menus & Tools +- `Ctrl+Space + \` - Tmux-menus main menu (navigate all tmux features) + - Also accessible via right-click on panes, windows, status bar +- `Ctrl+Space + Ctrl+f` - Tmux-fzf menu (fuzzy search sessions, windows, commands) +- `Ctrl+Space + Backspace` - Command palette (shows all available keybindings) +- `Ctrl+Space + Alt+m` - Command list palette (shows tmux commands) + +### Session Management +- `Ctrl+Space + d` - Detach from session +- `Ctrl+Space + Ctrl+Space` - Switch to last client +- `Ctrl+Space + Space` - Switch to last window + +### Window Management +- `Ctrl+Space + c` - New window (in current path) +- `Ctrl+Space + ,` - Rename window +- `Ctrl+Space + <` - Move window left +- `Ctrl+Space + >` - Move window right +- `Ctrl+Space + w` - List windows + +### Pane Management +- `Ctrl+Space + |` - Split horizontally +- `Ctrl+Space + -` - Split vertically +- `Ctrl+Space + \` - Full height split horizontal +- `Ctrl+Space + _` - Full width split vertical + +### Pane Navigation (Vim-style) +- `Ctrl+Space + h` - Move to left pane +- `Ctrl+Space + j` - Move to down pane +- `Ctrl+Space + k` - Move to up pane +- `Ctrl+Space + l` - Move to right pane + +### Pane Resizing +- `Ctrl+Space + Ctrl+h` - Resize pane left +- `Ctrl+Space + Ctrl+j` - Resize pane down +- `Ctrl+Space + Ctrl+k` - Resize pane up +- `Ctrl+Space + Ctrl+l` - Resize pane right + +### Pane Actions +- `Ctrl+Space + j` - Join pane from another window +- `Ctrl+Space + z` - Zoom/unzoom pane +- `Ctrl+Space + x` - Kill pane + +### Configuration +- `Ctrl+Space + r` - Reload tmux config + +## Zsh Keybindings + +### History Search +- `Ctrl+r` - FZF history search (fuzzy search all commands) +- `Ctrl+p` - Previous command in history (matching current input) +- `Ctrl+n` - Next command in history (matching current input) + +### FZF Integrations +- `Ctrl+t` - Search files/directories (paste to command line) +- `Alt+c` - Change directory with fzf +- `**` - Fuzzy completion for files + +### Navigation +- `cd ` - Change directory (zoxide enhanced) +- `cd -` - Go to previous directory + +## Shell Aliases + +### File Listing (eza) +- `ls` - Tree view with icons +- `ll` - Long list with icons +- `la` - Long list with hidden files +- `l` - Long list with git status + +### Utilities +- `vim` - Opens helix editor +- `c` - Clear screen +- `sp` - Spotify player + +## Tmux Plugins + +### Installed Plugins +- `tpm` - Tmux Plugin Manager +- `tmux-sensible` - Sensible default settings +- `dracula/tmux` - Dracula theme +- `tmux-resurrect` - Save/restore sessions +- `tmux-command-palette` - Command palette +- `tmux-tilish` - Tiling window manager keybindings +- `tmux-menus` - Context menus +- `tmux-fzf` - FZF integration + +### Plugin Management +- `Ctrl+Space + Shift+I` - Install plugins +- `Ctrl+Space + Shift+U` - Update plugins +- `Ctrl+Space + Alt+u` - Uninstall plugins + +## Git (via Oh My Zsh) + +### Common Aliases +- `gst` - git status +- `ga` - git add +- `gc` - git commit +- `gp` - git push +- `gl` - git pull +- `gco` - git checkout +- `gcb` - git checkout -b (new branch) +- `glog` - git log with graph + +## Tips & Tricks + +### Cheat Sheet +- `cheat` - View this cheat sheet +- `cheat -s ` - Search cheat sheet for term + +### Terminal Multiplexing +- Run `tmux` to start a new session +- Run `tmux attach` or `tmux a` to attach to existing session +- Sessions persist even after closing terminal + +### FZF Power User +- Use `Ctrl+r` for fuzzy command history +- Use `**` after any command for fuzzy file completion +- Example: `vim **` then type part of filename + +### Dotfiles Location +- Zsh config: `~/.zshrc` (source: `~/dotfiles/zsh/.zshrc`) +- Tmux config: `~/.config/tmux/tmux.conf` (source: `~/dotfiles/tmux/.config/tmux/tmux.conf`) +- Lazygit config: `~/.config/lazygit/config.yml` diff --git a/tmux/.config/tmux/plugins/tmux b/tmux/.config/tmux/plugins/tmux index 3323120..7ac1537 160000 --- a/tmux/.config/tmux/plugins/tmux +++ b/tmux/.config/tmux/plugins/tmux @@ -1 +1 @@ -Subproject commit 3323120e1705a9f4591870c9900e8a4b7c7e760d +Subproject commit 7ac15370df67124562d3857ab3a0f2eb9a55765d diff --git a/tmux/.config/tmux/plugins/tmux-command-palette b/tmux/.config/tmux/plugins/tmux-command-palette index 1f59677..dbcaf76 160000 --- a/tmux/.config/tmux/plugins/tmux-command-palette +++ b/tmux/.config/tmux/plugins/tmux-command-palette @@ -1 +1 @@ -Subproject commit 1f5967791184bfde616cd2bbc2c8a541588d8e37 +Subproject commit dbcaf7666a05b7af34f3ba38c0a67a751188df7a diff --git a/tmux/.config/tmux/plugins/tmux-fzf b/tmux/.config/tmux/plugins/tmux-fzf new file mode 160000 index 0000000..05af76d --- /dev/null +++ b/tmux/.config/tmux/plugins/tmux-fzf @@ -0,0 +1 @@ +Subproject commit 05af76daa2487575b93a4f604693b00969f19c2f diff --git a/tmux/.config/tmux/plugins/tmux-menus b/tmux/.config/tmux/plugins/tmux-menus new file mode 160000 index 0000000..879f56d --- /dev/null +++ b/tmux/.config/tmux/plugins/tmux-menus @@ -0,0 +1 @@ +Subproject commit 879f56df1b9703ac277fa16b9bbaf8705f2e6a1c diff --git a/tmux/.config/tmux/tmux.conf b/tmux/.config/tmux/tmux.conf index 2271117..a4b34dd 100644 --- a/tmux/.config/tmux/tmux.conf +++ b/tmux/.config/tmux/tmux.conf @@ -55,6 +55,8 @@ bind-key j select-pane -D bind-key k select-pane -U bind-key l select-pane -R +# joins pane from another window +bind-key j command-prompt -p "Join pane from window:" "join-pane -h -s '%%'" # List of plugins set -g @plugin 'tmux-plugins/tpm' @@ -63,6 +65,8 @@ set -g @plugin 'dracula/tmux' set -g @plugin 'tmux-plugins/tmux-resurrect' set -g @plugin 'lost-melody/tmux-command-palette' set -g @plugin 'jabirali/tmux-tilish' # https://github.com/jabirali/tmux-tilish?tab=readme-ov-file#keybindings +set -g @plugin 'jaclu/tmux-menus' +set -g @plugin 'sainnhe/tmux-fzf' set -g @dracula-show-powerline false set -g @dracula-show-flags false @@ -91,4 +95,7 @@ set -g @dracula-show-location false #Lazygit popup bind -r g popup -d '#{pane_current_path}' -E -w 90% -h 90% lazygit -run '~/.tmux/plugins/tpm/tpm' +#Cheat sheet popup +bind -r ? popup -E -w 85% -h 85% "glow -p ~/dotfiles/CHEATSHEET.md" + +run '~/.config/tmux/plugins/tpm/tpm' diff --git a/zsh/.zshrc b/zsh/.zshrc index 4eab51e..b6f6ceb 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -4,6 +4,8 @@ export QT_QPA_PLATFORMTHEME=qt5ct export QT_QPA_PLATFORMTHEME=qt6ct +# Add fzf to PATH +export PATH="$HOME/.fzf/bin:$PATH" # Path to your Oh My Zsh installation. export ZSH="$HOME/.oh-my-zsh" @@ -64,13 +66,8 @@ alias la='eza -la --icons' alias l='eza -la --icons --git' alias sp='spotify_player' - #alias zed="zeditor" -# Shell integrations -eval "$(fzf --zsh)" -eval "$(zoxide init --cmd cd zsh)" - # Set list of themes to pick from when loading at random # Setting this variable when ZSH_THEME=random will cause zsh to load # a theme from this variable instead of looking in $ZSH/themes/ @@ -136,6 +133,119 @@ plugins=(git starship azure docker docker-compose history zsh-interactive-cd ss source $ZSH/oh-my-zsh.sh source ~/git-flow-completion.zsh +# Shell integrations (loaded after Oh My Zsh to preserve keybindings) +if [[ $- == *i* ]]; then + eval "$(fzf --zsh)" + eval "$(zoxide init --cmd cd zsh)" +fi +# Custom functions +# Google search in Zen browser +google-search() { + local query="$*" + if [[ -z "$query" ]]; then + echo "Usage: ? " + return 1 + fi + # URL encode the query + local encoded=$(python3 -c "import urllib.parse; print(urllib.parse.quote('''$query'''))") + local url="https://www.google.com/search?q=${encoded}" + + # Try Zen browser first, fall back to default browser + if command -v zen-browser &> /dev/null; then + zen-browser "$url" &> /dev/null & + elif [[ -f "/mnt/c/Program Files/Zen Browser/zen.exe" ]]; then + "/mnt/c/Program Files/Zen Browser/zen.exe" "$url" &> /dev/null & + else + xdg-open "$url" &> /dev/null & + fi +} + +# Claude Code query +claude-query() { + local attach=false + + # Check for -a flag + if [[ "$1" == "-a" ]]; then + attach=true + shift + fi + + local query="$*" + if [[ -z "$query" ]]; then + echo "Usage: ?? [-a] " + echo " -a Open interactive Claude Code session" + return 1 + fi + + if [[ "$attach" == true ]]; then + # Interactive mode + claude "$query" + else + # Print mode (streaming output) + claude -p "$query" + fi +} + +# Cheat sheet viewer +cheat() { + local cheat_file="$HOME/dotfiles/CHEATSHEET.md" + + if [[ ! -f "$cheat_file" ]]; then + echo "Cheat sheet not found at $cheat_file" + return 1 + fi + + # Check for search flag + if [[ "$1" == "-s" ]]; then + shift + local search_term="$*" + if [[ -z "$search_term" ]]; then + # Interactive search with fzf + if command -v bat &> /dev/null; then + grep -n "." "$cheat_file" | fzf --delimiter=: --preview 'bat --color=always --style=plain --highlight-line {1} '"$cheat_file" --preview-window=+{1}-10 + else + grep -n "." "$cheat_file" | fzf --delimiter=: --preview 'sed -n {1}p '"$cheat_file" + fi + else + # Search for specific term + grep -i "$search_term" "$cheat_file" --color=always + fi + elif [[ "$1" == "-p" ]] || [[ -n "$TMUX" && "$1" != "-f" ]]; then + # Show in tmux popup (if in tmux) or with -p flag + if [[ -n "$TMUX" ]]; then + if command -v glow &> /dev/null; then + tmux popup -E -w 85% -h 85% "glow -p '$cheat_file'" + elif command -v bat &> /dev/null; then + tmux popup -E -w 85% -h 85% "bat --style=full --paging=always '$cheat_file'" + else + tmux popup -E -w 85% -h 85% "less '$cheat_file'" + fi + else + # Not in tmux, fall back to regular view + if command -v glow &> /dev/null; then + glow -p "$cheat_file" + elif command -v bat &> /dev/null; then + bat --style=full "$cheat_file" + else + less "$cheat_file" + fi + fi + else + # Regular view with glow, bat or less + if command -v glow &> /dev/null; then + glow -p "$cheat_file" + elif command -v bat &> /dev/null; then + bat --style=full "$cheat_file" + else + less "$cheat_file" + fi + fi +} + +# Aliases with noglob to prevent glob expansion +alias '?'='noglob google-search' +alias '??'='noglob claude-query' + # User configuration # export MANPATH="/usr/local/man:$MANPATH" @@ -168,9 +278,18 @@ source ~/git-flow-completion.zsh export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +# Welcome message (only in interactive shells) +if [[ $- == *i* ]]; then + # Add a small delay to let terminal initialize + sleep 0.1 + echo "💡 Tip: Type 'cheat' to view terminal shortcuts (or Ctrl+Space+? in tmux)" +fi + export PATH="/home/seano/.npm-global/bin:$PATH" . "$HOME/.local/bin/env" export PATH="$HOME/.local/bin:$PATH" export PATH="$HOME/.local/bin:$PATH" export PATH="$HOME/.local/bin:$PATH" +