mirror of
https://github.com/hydroxycarbamide/dotfiles.git
synced 2025-05-07 21:39:07 -04:00
Add nnn
This commit is contained in:
parent
0ef5de12ac
commit
c0889285ff
58 changed files with 5175 additions and 0 deletions
40
dot_config/nnn/plugins/executable_fzhist
Normal file
40
dot_config/nnn/plugins/executable_fzhist
Normal file
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# Description: Fuzzy find a command from history,
|
||||
# edit in $EDITOR and run as a command
|
||||
#
|
||||
# Note: Supports only bash and fish history
|
||||
#
|
||||
# Shell: POSIX compliant
|
||||
# Author: Arun Prakash Jana
|
||||
|
||||
if type fzf >/dev/null 2>&1; then
|
||||
fuzzy=fzf
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
shellname="$(basename "$SHELL")"
|
||||
|
||||
if [ "$shellname" = "bash" ]; then
|
||||
hist_file="$HOME/.bash_history"
|
||||
entry="$("$fuzzy" < "$hist_file")"
|
||||
elif [ "$shellname" = "fish" ]; then
|
||||
hist_file="$HOME/.local/share/fish/fish_history"
|
||||
entry="$(grep "\- cmd: " "$hist_file" | cut -c 8- | "$fuzzy")"
|
||||
fi
|
||||
|
||||
if [ -n "$entry" ]; then
|
||||
tmpfile=$(mktemp)
|
||||
echo "$entry" >> "$tmpfile"
|
||||
$EDITOR "$tmpfile"
|
||||
|
||||
if [ -s "$tmpfile" ]; then
|
||||
$SHELL -c "$(cat "$tmpfile")"
|
||||
fi
|
||||
|
||||
rm "$tmpfile"
|
||||
|
||||
printf "Press any key to exit"
|
||||
read -r _
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue