mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-19 09:03:43 -05:00
Updated Examples (markdown)
14
Examples.md
14
Examples.md
@@ -167,23 +167,23 @@ f() {
|
||||
# ADD A REPEATABLE COMMAND TO THE BASH HISTORY ############################
|
||||
# Store the arguments in a temporary file for sanitising before being
|
||||
# entered into bash history
|
||||
: > ~/.fzf_tmp
|
||||
: > /tmp/fzf_tmp
|
||||
for file in ${arguments[@]}; do
|
||||
echo $file >> ~/.fzf_tmp
|
||||
echo $file >> /tmp/fzf_tmp
|
||||
done
|
||||
|
||||
# Put all input arguments on one line and sanitise the command such that
|
||||
# spaces and parentheses are properly escaped. More sanitisation
|
||||
# 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 [[ $1 =~ ^(zathura|vlc|eog|kolourpaint)$ ]]; then
|
||||
sed -i '${s/$/ \&/}' ~/.fzf_tmp
|
||||
sed -i '${s/$/ \&/}' /tmp/fzf_tmp
|
||||
fi
|
||||
|
||||
# Grab the sanitised arguments
|
||||
arguments=$(cat ~/.fzf_tmp)
|
||||
arguments=$(cat /tmp/fzf_tmp)
|
||||
|
||||
# Add the command with the sanitised arguments to our .bash_history
|
||||
echo ${1} ${arguments} >> ~/.bash_history
|
||||
@@ -192,8 +192,8 @@ f() {
|
||||
history -r
|
||||
|
||||
# Clean up temporary variables
|
||||
rm ~/.fzf_tmp
|
||||
}
|
||||
rm /tmp/fzf_tmp
|
||||
}
|
||||
```
|
||||
|
||||
```sh
|
||||
|
||||
Reference in New Issue
Block a user