mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-19 09:03:43 -05:00
Updated Examples (markdown)
24
Examples.md
24
Examples.md
@@ -118,7 +118,7 @@ f() {
|
|||||||
# Remove first argument off the list
|
# Remove first argument off the list
|
||||||
shift
|
shift
|
||||||
|
|
||||||
# Store option flags
|
# Store option flags with separating spaces, or just set as single space
|
||||||
options="$@"
|
options="$@"
|
||||||
if [ -z "${options}" ]; then
|
if [ -z "${options}" ]; then
|
||||||
options=" "
|
options=" "
|
||||||
@@ -139,23 +139,6 @@ f() {
|
|||||||
# fzf, then we'll load it all back into the shell's active history
|
# fzf, then we'll load it all back into the shell's active history
|
||||||
history -w
|
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 ############################
|
# ADD A REPEATABLE COMMAND TO THE BASH HISTORY ############################
|
||||||
# Store the arguments in a temporary file for sanitising before being
|
# Store the arguments in a temporary file for sanitising before being
|
||||||
# entered into bash history
|
# entered into bash history
|
||||||
@@ -169,7 +152,7 @@ f() {
|
|||||||
# next to any pre-existing single quotes in the raw argument
|
# next to any pre-existing single quotes in the raw argument
|
||||||
sed -i "s/'/''/g; s/.*/'&'/g; s/\n//g" /tmp/fzf_tmp
|
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
|
if [[ "$program" =~ ^(nautilus|zathura|evince|vlc|eog|kolourpaint)$ ]]; then
|
||||||
sed -i '${s/$/ \&/}' /tmp/fzf_tmp
|
sed -i '${s/$/ \&/}' /tmp/fzf_tmp
|
||||||
fi
|
fi
|
||||||
@@ -183,6 +166,9 @@ f() {
|
|||||||
# Reload the ~/.bash_history into the shell's active history
|
# Reload the ~/.bash_history into the shell's active history
|
||||||
history -r
|
history -r
|
||||||
|
|
||||||
|
# EXECUTE THE LAST COMMAND IN ~/.bash_history #############################
|
||||||
|
fc -s -1
|
||||||
|
|
||||||
# Clean up temporary variables
|
# Clean up temporary variables
|
||||||
rm /tmp/fzf_tmp
|
rm /tmp/fzf_tmp
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user