mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 13:46:41 +00:00
feat(shell): major refactor around history and completion setup
Biggest change is embracing fzf for all shell completion. This includes using tmux popup windows to effectively render completions as floating popups with fuzzy matching via fzf. Shell history has also been improved, with appending each command to the history file one by one, rather than only at end of a shell session when the shell exists. This should ensure I don't have any more lost commands cause the shell didn't exit cleanly.
This commit is contained in:
18
zsh/fzf.zsh
18
zsh/fzf.zsh
@@ -1,18 +0,0 @@
|
||||
#
|
||||
# fzf
|
||||
#
|
||||
|
||||
export FZF_CTRL_T_OPTS="--preview='less {}'"
|
||||
export FZF_DEFAULT_OPTS="--bind=ctrl-k:kill-line --border=none --tabstop=4"
|
||||
export FZF_TMUX=0
|
||||
export FZF_TMUX_HEIGHT=100%
|
||||
|
||||
# Install fzf binary from latest GitHub Release.
|
||||
zinit light-mode wait lucid from'gh-r' as'program' pick'fzf' \
|
||||
for @junegunn/fzf
|
||||
|
||||
# Install fzf-tmux command and zsh plugins from default branch on GitHub.
|
||||
zinit light-mode wait lucid from'gh' as'program' pick'bin/fzf-tmux' \
|
||||
multisrc'shell/{completion,key-bindings}.zsh' \
|
||||
id-as'junegunn/fzf-extras' \
|
||||
for @junegunn/fzf
|
||||
@@ -2,6 +2,13 @@
|
||||
# Ruby environment setup.
|
||||
#
|
||||
|
||||
# ==============================================================================
|
||||
# bundler
|
||||
# ==============================================================================
|
||||
|
||||
# Enable Ruby Bundler plugin from oh-my-zsh.
|
||||
zinit for @OMZ::plugins/bundler
|
||||
|
||||
# ==============================================================================
|
||||
# aliases
|
||||
# ==============================================================================
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Interactive Utility Functions
|
||||
# zshrc helper functions
|
||||
#
|
||||
# Helpers designed for use during setup of interactive shell environments
|
||||
# (~/.zshrc ).
|
||||
@@ -36,32 +36,32 @@
|
||||
setup-completions() {
|
||||
local cmd="$1"
|
||||
local source="$2"
|
||||
local setup_cmd="$3"
|
||||
shift 3
|
||||
shift 2
|
||||
local script="$@"
|
||||
|
||||
local target_dir="${ZSH_COMPLETIONS:-$HOME/.zsh/completions}"
|
||||
local target_file="${target_dir}/_${cmd}"
|
||||
|
||||
if [[ -z "$cmd" || -z "$source" || -z "$script" ]]; then
|
||||
echo "setup-completions: Missing required arguments." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ -z "$(command -v "$cmd")" ]]; then
|
||||
echo "setup-completions: Command not found: $cmd" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ -z "$(command -v "$setup_cmd")" ]]; then
|
||||
echo "setup-completions: Command not found: $setup_cmd" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ -z "$cmd" || -z "$source" || -z "$setup_cmd" ]]; then
|
||||
echo "setup-completions: Missing required arguments." >&2
|
||||
if [[ -z "$source" ]]; then
|
||||
echo "setup-completions: Source file not found: $source" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check if the target completion file needs to be updated
|
||||
if [[ ! -f "$target_file" || "$source" -nt "$target_file" ]]; then
|
||||
echo "setup-completions: Setting up completion for $cmd --> $target_file" >&2
|
||||
echo "setup-completions: Setting up completion for $cmd: $script" >&2
|
||||
mkdir -p "$target_dir"
|
||||
"$setup_cmd" "$@" >| "$target_file"
|
||||
eval "$script" >| "$target_file"
|
||||
chmod +x "$target_file"
|
||||
|
||||
# Only run compinit if not already loaded
|
||||
Reference in New Issue
Block a user