m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-19 09:03:43 -05:00

Updated Examples (markdown)

Matthew Bennett
2021-04-18 02:38:28 +02:00
parent f983acd57a
commit 8c0111a495

@@ -118,7 +118,7 @@ f() {
# Remove first argument off the list
shift
# Store option flags
# Store option flags with separating spaces, or just set as single space
options="$@"
if [ -z "${options}" ]; then
options=" "
@@ -139,23 +139,6 @@ f() {
# fzf, then we'll load it all back into the shell's active history
history -w
# RUN THE COMMANDS ########################################################
# The cd command has no effect when run as background, and doesn't show up
# as a job the can be brought to the foreground. So we make sure not to add
# a '&' (more programs can be added separated by a '|')
if ! [[ $program =~ ^(cd)$ ]]; then
$program$options${arguments[@]} &
else
$program$options${arguments[@]}
fi
# If the program is not on the list of GUIs (e.g. vim, cat, etc.) bring it
# to foreground so we can see the output. Also put cd on this list
# otherwise there will be errors)
if ! [[ "$program" =~ ^(cd|nautilus|zathura|evince|vlc|eog|kolourpaint)$ ]]; then
fg %%
fi
# ADD A REPEATABLE COMMAND TO THE BASH HISTORY ############################
# Store the arguments in a temporary file for sanitising before being
# entered into bash history
@@ -169,7 +152,7 @@ f() {
# next to any pre-existing single quotes in the raw argument
sed -i "s/'/''/g; s/.*/'&'/g; s/\n//g" /tmp/fzf_tmp
# If the program is on the GUI list add a '&' to the command history
# If the program is on the GUI list, add a '&' to the command history
if [[ "$program" =~ ^(nautilus|zathura|evince|vlc|eog|kolourpaint)$ ]]; then
sed -i '${s/$/ \&/}' /tmp/fzf_tmp
fi
@@ -183,6 +166,9 @@ f() {
# Reload the ~/.bash_history into the shell's active history
history -r
# EXECUTE THE LAST COMMAND IN ~/.bash_history #############################
fc -s -1
# Clean up temporary variables
rm /tmp/fzf_tmp
}