Created
November 12, 2019 13:23
-
-
Save giacgiuliari/1e000a45189161d936132c03aa71446e to your computer and use it in GitHub Desktop.
Magic fastcommand script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### EXPERIMENTAL | |
# Requires fzf | |
# Paste this in .bashrc | |
# The default command file id ~/.commands | |
COMMANDS_FILE="~/.commands" | |
__best_command__(){ | |
local cmd | |
shopt -u nocaseglob nocasematch | |
# cmd=$(cat $COMMANDS_FILE | fzf --height 50% | command grep '^ *[0-9]') && | |
cmd=$(cat $COMMANDS_FILE | fzf --height 50%) | |
sed 's/^ *\([0-9]*\)\** *//' <<< "$cmd" | sed 's/.*\t//' | |
} | |
__save_command__(){ | |
local save | |
set -o history -o histexpand | |
last_cmd=$(echo `history |tail -n2 |head -n1` | sed 's/[0-9]* //') | |
read -p "Insert brief textual desctiption: " usrin | |
echo "$usrin\t$last_cmd" | |
} | |
bind '"\er": redraw-current-line' | |
bind '"\e^": history-expand-line' | |
bind '"\C-x\C-x": " \C-e\C-u\C-y\ey\C-u`__best_command__`\e\C-e\er\e^"' | |
bind '"\C-x\C-a": "\e echo -e `__save_command__` >> $COMMANDS_FILE \n"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment