m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-18 08:13:40 -05:00

Fix commands using xargs, which causes errors if the user quits fzf without making any selection.

Okan Esen
2018-07-22 00:54:53 +02:00
parent e7a944950a
commit 39721be134

@@ -97,25 +97,25 @@ end
```fish
function fco -d "Fuzzy-find and checkout a branch"
git branch --all | grep -v HEAD | string trim | fzf | xargs git checkout
git branch --all | grep -v HEAD | string trim | fzf | read -l result; and git checkout "$result"
end
function fcoc -d "Fuzzy-find and checkout a commit"
git log --pretty=oneline --abbrev-commit --reverse | fzf --tac +s -e | awk '{print $1;}' | xargs git checkout
git log --pretty=oneline --abbrev-commit --reverse | fzf --tac +s -e | awk '{print $1;}' | read -l result; and git checkout "$result"
end
```
### SSH
```fish
function fssh -d "Fuzzy-find ssh host and ssh into it"
ag '^host [^*]' ~/.ssh/config | cut -d ' ' -f 2 | fzf | xargs -o ssh
function fssh -d "Fuzzy-find ssh host via ag and ssh into it"
ag --ignore-case '^host [^*]' ~/.ssh/config | cut -d ' ' -f 2 | fzf | read -l result; and ssh "$result"
end
```
### Tmux
```fish
function fs -d "Switch tmux session"
tmux list-sessions -F "#{session_name}" | fzf | xargs tmux switch-client -t
tmux list-sessions -F "#{session_name}" | fzf | read -l result; and tmux switch-client -t "$result"
end
```
@@ -130,6 +130,6 @@ function fpass -d "Fuzzy-find a Lastpass entry and copy the password"
exit
end
lpass ls | fzf | string replace -r -a '.+\[id: (\d+)\]' '$1' | xargs lpass show -c --password
lpass ls | fzf | string replace -r -a '.+\[id: (\d+)\]' '$1' | read -l result; and lpass show -c --password "$result"
end
```