Skip to content

Instantly share code, notes, and snippets.

@michaelavila
Created November 4, 2014 21:19
Show Gist options
  • Save michaelavila/ba3ca96bd5a066462f51 to your computer and use it in GitHub Desktop.
Save michaelavila/ba3ca96bd5a066462f51 to your computer and use it in GitHub Desktop.
Selecta Pres Resources
[alias]
find-branch = !git branch | cut -c 3- | selecta | xargs git checkout
" You will need to have selecta installed AND the selecta.vim plugin installed
" Use selecta to find files to edit
nnoremap <leader>e :call SelectaFile()<cr>
nnoremap <leader>b :call SelectaBuffer()<cr>
" Use selecta to find commands to run
nnoremap <leader>h :call SelectaHistoryCommand()<cr>
# By default, ^S freezes terminal output and ^Q resumes it. Disable that so
# that those keys can be used for other things.
unsetopt flowcontrol
# Run Selecta in the current working directory, appending the selected path, if
# any, to the current command.
function insert-selecta-path-in-command-line() {
local selected_path
# Print a newline or we'll clobber the old prompt.
echo
# Find the path; abort if the user doesn't select anything.
selected_path=$(find . -type f -not -ipath "*.git/*" | selecta) || return
# Append the selection to the current command buffer.
eval 'LBUFFER="$LBUFFER$selected_path"'
# Redraw the prompt since Selecta has drawn several new lines of text.
zle reset-prompt
}
# Create the zle widget
zle -N insert-selecta-path-in-command-line
# Bind the key to the newly created widget
bindkey "^S" "insert-selecta-path-in-command-line"
# fuzzy select and kill processes from ps aux
alias zap="ps aux | tail -n+2 | selecta | tr -s ' ' | cut -d ' ' -f 2 | xargs kill -9"
# fuzzy select directory and cd to it
alias sd='cd $(find * -type d | selecta)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment