1
Fork 0

fzf stuff

This commit is contained in:
Hadeed 2023-08-30 07:00:57 +05:00
parent 5b02501e0f
commit 11f9f923d0
7 changed files with 42 additions and 27 deletions

View file

@ -1,4 +1,6 @@
bat bat
bear
ccls
exa exa
fd fd
kitty kitty

View file

@ -11,7 +11,7 @@ return {
cmp.setup { cmp.setup {
mapping = cmp.mapping.preset.insert { mapping = cmp.mapping.preset.insert {
["<C-K>"] = function(fallback) ["<C-Y>"] = function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.confirm { select=true } cmp.confirm { select=true }
else else

View file

@ -1,6 +1,15 @@
function create_dir() [ ! -d "$1" ] && mkdir -p "$1" function create_dir() [ ! -d "$1" ] && mkdir -p "$1"
function safe_source() [ -f "$1" ] && source "$1" function safe_source() [ -f "$1" ] && source "$1"
function zsh_add_file() safe_source "$ZDOTDIR/$1" function zsh_add_file() safe_source "$ZDOTDIR/$1"
function zsh_add_plugin() {
PLUGIN_NAME=$(echo $1 | cut -d "/" -f 2)
[ ! -d "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME" ] &&
git clone "https://github.com/$1.git" "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME"
safe_source "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME/$PLUGIN_NAME.plugin.zsh"
safe_source "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME/$PLUGIN_NAME.zsh"
}
zsh_add_file "zsh-aliases" zsh_add_file "zsh-aliases"
zsh_add_file "zsh-functions" zsh_add_file "zsh-functions"
@ -12,16 +21,7 @@ zsh_add_plugin "zdharma-continuum/fast-syntax-highlighting"
zsh_add_plugin "zsh-users/zsh-autosuggestions" zsh_add_plugin "zsh-users/zsh-autosuggestions"
zsh_add_plugin "zsh-users/zsh-completions" zsh_add_plugin "zsh-users/zsh-completions"
create_dir "$HOME/.cache/zsh" zsh_add_file "zsh-completions"
autoload -Uz compinit && compinit -d "$HOME/.cache/zsh/zcompdump" zsh_add_file "zsh-bindings"
zmodload zsh/complist
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
autoload -z edit-command-line
zle -N edit-command-line
bindkey -e
bindkey "^V" edit-command-line
bindkey '^K' autosuggest-execute
# vim: filetype=zsh # vim: filetype=zsh

8
zsh/zsh-bindings Normal file
View file

@ -0,0 +1,8 @@
autoload -z edit-command-line
zle -N edit-command-line
bindkey "^V" edit-command-line
bindkey '^Y' autosuggest-execute
bindkey '^F' find-directory
# vim: filetype=zsh

7
zsh/zsh-completion Normal file
View file

@ -0,0 +1,7 @@
create_dir "$HOME/.cache/zsh"
autoload -Uz compinit
compinit -d "$HOME/.cache/zsh/zcompdump"
zmodload zsh/complist
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
# vim: filetype=zsh

View file

@ -1,21 +1,6 @@
function zsh_add_plugin() {
PLUGIN_NAME=$(echo $1 | cut -d "/" -f 2)
[ ! -d "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME" ] &&
git clone "https://github.com/$1.git" "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME"
safe_source "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME/$PLUGIN_NAME.plugin.zsh"
safe_source "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME/$PLUGIN_NAME.zsh"
}
function cc() python -c "from math import *; print($*)" function cc() python -c "from math import *; print($*)"
function mkcd() mkdir -p -- $1 && cd -- $1 function mkcd() mkdir -p -- $1 && cd -- $1
function serve() {
gem list -i '^webrick$' > /dev/null || gem install webrick
ruby -run -e httpd . -p 3000
}
function save-ssh-key() { function save-ssh-key() {
mv "$1" "$HOME/.ssh/${1}_${2}" mv "$1" "$HOME/.ssh/${1}_${2}"
mv "$1.pub" "$HOME/.ssh/${1}_${2}.pub" mv "$1.pub" "$HOME/.ssh/${1}_${2}.pub"
@ -25,4 +10,15 @@ function eik() {
kitten edit-in-kitty "$1" kitten edit-in-kitty "$1"
} }
function find-directory() {
FOLDER=$(fd -t d --hidden | fzf --height "50%" --reverse)
if [ -n "$FOLDER" ]; then
BUFFER="cd $FOLDER"
zle .accept-line
else
zle reset-prompt
fi
}
zle -N find-directory
# vim: filetype=zsh # vim: filetype=zsh

View file

@ -11,6 +11,8 @@ setopt INC_APPEND_HISTORY
setopt RM_STAR_SILENT setopt RM_STAR_SILENT
setopt NO_BEEP setopt NO_BEEP
bindkey -e
stty stop undef stty stop undef
zle_highlight=("paste:none") zle_highlight=("paste:none")