mirror of
https://github.com/GRFreire/dotfiles.git
synced 2026-01-10 04:19:38 +00:00
refactor fzf file to edit chooser
Changes: - Refactored into a function, instead of alias - Renamed to fzf_fast_file_edit, in place of ce, which is more descriptive - Made the code easier to read and edit
This commit is contained in:
parent
094943b469
commit
442e25b497
@ -40,9 +40,23 @@ alias config="git --git-dir=\$HOME/.dotfiles/ --work-tree=\$HOME"
|
|||||||
alias pacs="pacman -Slq | fzf --multi --preview 'pacman -Si {1}' | xargs -ro sudo pacman -S"
|
alias pacs="pacman -Slq | fzf --multi --preview 'pacman -Si {1}' | xargs -ro sudo pacman -S"
|
||||||
alias apacs="paru -Slq | fzf --multi --preview 'paru -Si {1}' | xargs -ro paru -S"
|
alias apacs="paru -Slq | fzf --multi --preview 'paru -Si {1}' | xargs -ro paru -S"
|
||||||
|
|
||||||
# Config/scripts Edit
|
fzf_fast_file_edit() {
|
||||||
alias ce="echo \"\$(/bin/ls \$HOME/.scripts/bin | sed \"s|^|\$(realpath \$HOME/.scripts/bin/ --relative-to=.)/|\")\n\$((cd \$HOME && config ls-tree -r master --name-only \$HOME) | sed \"s|^|\$(realpath \$HOME --relative-to=.)/|\" | sed 's|^\./||')\" | fzf --info=inline --prompt='Select a file: ' --preview='bat --paging=never --style=plain --color=always {}' | xargs -r \$(echo \$EDITOR)"
|
# Get scripts
|
||||||
bindkey -s '^[^E' 'ce\n'
|
scripts="$(/bin/ls "$HOME/.scripts/bin" | sed "s|^|$(realpath "$HOME"/.scripts/bin/ --relative-to=.)/|")"
|
||||||
|
|
||||||
|
# Get config files
|
||||||
|
current_branch="$(config rev-parse --abbrev-ref HEAD)"
|
||||||
|
config_files="$(config ls-tree -r "$current_branch" --name-only "$HOME")"
|
||||||
|
|
||||||
|
# Select file
|
||||||
|
selected_file=$(printf "%s\n%s" "$scripts" "$config_files" | fzf --info=inline --prompt='Select a file: ' --preview='bat --paging=never --style=plain --color=always {}')
|
||||||
|
|
||||||
|
|
||||||
|
if [ -n "$selected_file" ]; then
|
||||||
|
$EDITOR "$selected_file"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
bindkey -s '^[^E' 'fzf_fast_file_edit\n'
|
||||||
|
|
||||||
# Alias for python3
|
# Alias for python3
|
||||||
alias python="python3"
|
alias python="python3"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user