mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-19 09:03:43 -05:00
Fix commands using xargs, which causes errors if the user quits fzf without making any selection.
@@ -97,25 +97,25 @@ end
|
|||||||
|
|
||||||
```fish
|
```fish
|
||||||
function fco -d "Fuzzy-find and checkout a branch"
|
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
|
end
|
||||||
|
|
||||||
function fcoc -d "Fuzzy-find and checkout a commit"
|
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
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
### SSH
|
### SSH
|
||||||
```fish
|
```fish
|
||||||
function fssh -d "Fuzzy-find ssh host and ssh into it"
|
function fssh -d "Fuzzy-find ssh host via ag and ssh into it"
|
||||||
ag '^host [^*]' ~/.ssh/config | cut -d ' ' -f 2 | fzf | xargs -o ssh
|
ag --ignore-case '^host [^*]' ~/.ssh/config | cut -d ' ' -f 2 | fzf | read -l result; and ssh "$result"
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
### Tmux
|
### Tmux
|
||||||
```fish
|
```fish
|
||||||
function fs -d "Switch tmux session"
|
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
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -130,6 +130,6 @@ function fpass -d "Fuzzy-find a Lastpass entry and copy the password"
|
|||||||
exit
|
exit
|
||||||
end
|
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
|
end
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user