Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Q] I don't know what I'm doing wrong, but this just doesn't work for me #497

Open
gonstoll opened this issue Dec 5, 2024 · 0 comments
Open
Labels
question Further information is requested

Comments

@gonstoll
Copy link

gonstoll commented Dec 5, 2024

This is my zshrc:

if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

ZSHRC_PATH="$(readlink -f - $HOME/.config/zsh)/.zshrc" # get the path of the .zshrc symlink
ZSH_PATH=$(dirname $ZSHRC_PATH) # get the path of the zsh folder
LANG=en_US.UTF-8

# Options
setopt correct
setopt extendedglob
setopt nocaseglob
setopt rcexpandparam
setopt nobeep
setopt appendhistory
setopt inc_append_history
setopt histignorealldups
setopt autocd
setopt histignorespace
setopt share_history
setopt hist_expire_dups_first
setopt hist_ignore_dups
setopt hist_verify
setopt always_to_end
setopt hist_expire_dups_first
setopt hist_find_no_dups
setopt interactivecomments

# Alias
alias fd="cd ~ && cd \$(find * -type d | fzf)" # cd into a directory
alias lg="lazygit"
alias g="git"
alias vim="nvim"
alias ..="cd .. && cd .."
alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin
alias s="tmux-sessionizer"
alias tn="tmux new -s $(pwd | sed 's/.*\///g')"
alias cat="bat"

if [[ -f $ZSH_PATH/config/custom.zsh ]]; then
  source $ZSH_PATH/config/custom.zsh
fi

# Completions
FPATH=$(brew --prefix)/share/zsh-completions:$FPATH

# History
HISTFILE=$ZDOTDIR/.histfile
HISTSIZE=1100000000
SAVEHIST=1000000000
bindkey "^[[A" history-search-backward
bindkey "^[[B" history-search-forward
bindkey -s "^FS" "s\n" # Start tmux-sessionizer. Make sure "s" is an alias that executes "tmux-sessionizer"

# Disable the highlighting of text pasted into the terminal.
zle_highlight=('paste:none')

autoload -U compinit; compinit
autoload -U colors; colors

source $ZSH_PATH/plugins/powerlevel10k/powerlevel10k.zsh-theme

# To customize prompt, run `p10k configure` or edit ~/.config/zsh//.p10k.zsh.
[[ ! -f $ZSH_PATH/.p10k.zsh ]] || source $ZSH_PATH/.p10k.zsh

# Variables
if [[ -n $SSH_CONNECTION ]]; then
  export VISUAL='vim'
  export EDITOR='vim'
  export GIT_EDITOR='vim'
else
  export EDITOR="$(which nvim)"
  export VISUAL="$EDITOR"
  export GIT_EDITOR="$EDITOR"
fi

export TERM="wezterm"
export TERMINFO="$HOME/.terminfo/"

if [[ -s "$HOME/.config/bun/_bun" ]]; then
  source "$HOME/.config/bun/_bun"
fi
export BUN_INSTALL="$HOME/.config/bun"
export PATH=$HOME/.local/bin:$PATH
export PATH=$HOME/.config/bin:$HOME/.config/tmux/bin:$PATH
export PATH="$BUN_INSTALL/bin:$PATH"

# Plugins
source $ZSH_PATH/plugins/fzf/fzf.zsh
source $ZSH_PATH/plugins/fzf-tab/fzf-tab.plugin.zsh
source $ZSH_PATH/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh
source $ZSH_PATH/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh

# Zoxide
eval "$(zoxide init zsh)"

# Tmux
export T_FZF_BORDER_LABEL='tmux finder'
export FZF_TMUX_OPTS="-p 100%,100%"

# Fzf
source <(fzf --zsh)
show_file_or_dir_preview="if [ -d {} ]; then eza --tree --color=always {} | head -200; else bat -n --color=always --line-range :500 {}; fi"
export FZF_CTRL_T_OPTS="--preview '$show_file_or_dir_preview'"

# Advanced customization of fzf options via _fzf_comprun function
# - The first argument to the function is the name of the command.
# - You should make sure to pass the rest of the arguments to fzf.
function _fzf_comprun() {
  local command=$1
  shift

  case "$command" in
    cd)           fzf --preview 'eza --tree --color=always {} | head -200' "$@" ;;
    export|unset) fzf --preview "eval 'echo \${}'"         "$@" ;;
    ssh)          fzf --preview 'dig {}'                   "$@" ;;
    *)            fzf --preview "$show_file_or_dir_preview" "$@" ;;
  esac
}

# bun completions
[ -s "$HOME/.config/bun/_bun" ] && source "$HOME/.config/bun/_bun"

# rust
export RUSTUP_HOME="$HOME/.config/rust/.rustup"
export CARGO_HOME="$HOME/.config/rust/.cargo"

# Eza (better ls)
alias ls="eza --icons=always"

# Bat
export BAT_CONFIG_PATH="$HOME/.config/bat/bat.conf"

# Yazi (file manager system)
# Use y to change the current directory when exiting yazi
function y() {
  local tmp="$(mktemp -t "yazi-cwd.XXXXXX")"
  yazi "$@" --cwd-file="$tmp"
  if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
    cd -- "$cwd"
  fi
  rm -f -- "$tmp"
}

# Edit command line in vim
autoload -U edit-command-line
zle -N edit-command-line
bindkey "^X^E" edit-command-line

# Use fzf for history search
# bindkey '^R' fzf-history-widget

export MANPAGER='nvim +Man!'

# Use fzf to view and focus on aerospace windows
function ff() {
  aerospace list-windows --all | fzf --bind 'enter:execute(bash -c "aerospace focus --window-id {1}")+abort'
}

zstyle ':completion:*:git-checkout:*' sort false
zstyle ':completion:*:descriptions' format '[%d]'
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' menu no
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath'
zstyle ':fzf-tab:*' fzf-flags --color=fg:1,fg+:2 --bind=tab:accept
zstyle ':fzf-tab:*' use-fzf-default-opts yes
zstyle ':fzf-tab:*' switch-group '<' '>'

No matter what I try I don't get this to work 😭 to be perfectly honest, a bunch of other stuff doesn't work, such as zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} never actually working before, or fzf's * completions. So there must be something I'm messing up with my configuration?

@gonstoll gonstoll added the question Further information is requested label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant