mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-20 01:23:43 -05:00
Updated Examples (markdown)
12
Examples.md
12
Examples.md
@@ -167,23 +167,23 @@ f() {
|
|||||||
# 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
|
||||||
: > ~/.fzf_tmp
|
: > /tmp/fzf_tmp
|
||||||
for file in ${arguments[@]}; do
|
for file in ${arguments[@]}; do
|
||||||
echo $file >> ~/.fzf_tmp
|
echo $file >> /tmp/fzf_tmp
|
||||||
done
|
done
|
||||||
|
|
||||||
# Put all input arguments on one line and sanitise the command such that
|
# Put all input arguments on one line and sanitise the command such that
|
||||||
# spaces and parentheses are properly escaped. More sanitisation
|
# spaces and parentheses are properly escaped. More sanitisation
|
||||||
# substitutions can be added if needed
|
# substitutions can be added if needed
|
||||||
sed -i 's/\n//g; s/ /\\ /g; s/(/\\(/; s/)/\\)/' ~/.fzf_tmp
|
sed -i 's/\n//g; s/ /\\ /g; s/(/\\(/; s/)/\\)/' /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 [[ $1 =~ ^(zathura|vlc|eog|kolourpaint)$ ]]; then
|
if [[ $1 =~ ^(zathura|vlc|eog|kolourpaint)$ ]]; then
|
||||||
sed -i '${s/$/ \&/}' ~/.fzf_tmp
|
sed -i '${s/$/ \&/}' /tmp/fzf_tmp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Grab the sanitised arguments
|
# Grab the sanitised arguments
|
||||||
arguments=$(cat ~/.fzf_tmp)
|
arguments=$(cat /tmp/fzf_tmp)
|
||||||
|
|
||||||
# Add the command with the sanitised arguments to our .bash_history
|
# Add the command with the sanitised arguments to our .bash_history
|
||||||
echo ${1} ${arguments} >> ~/.bash_history
|
echo ${1} ${arguments} >> ~/.bash_history
|
||||||
@@ -192,7 +192,7 @@ f() {
|
|||||||
history -r
|
history -r
|
||||||
|
|
||||||
# Clean up temporary variables
|
# Clean up temporary variables
|
||||||
rm ~/.fzf_tmp
|
rm /tmp/fzf_tmp
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user