mirror of
https://github.com/junegunn/fzf.git
synced 2026-10-13 00:20:20 +08:00
Update README and install script
- Added examples: fbr and fco - Always use local variables
This commit is contained in:
1 parent
c6acb2a639
commit
f4c5aa03d7
2 files changed
+24
-4
No files matched your search
@@ -133,17 +133,20 @@ Useful examples
|
||||
```sh
|
||||
# vimf - Open selected file in Vim
|
||||
vimf() {
|
||||
FILE=$(fzf) && vim "$FILE"
|
||||
local file
|
||||
file=$(fzf) && vim "$file"
|
||||
}
|
||||
|
||||
# fd - cd to selected directory
|
||||
fd() {
|
||||
DIR=$(find ${1:-*} -path '*/\.*' -prune -o -type d -print 2> /dev/null | fzf) && cd "$DIR"
|
||||
local dir
|
||||
dir=$(find ${1:-*} -path '*/\.*' -prune -o -type d -print 2> /dev/null | fzf) && cd "$dir"
|
||||
}
|
||||
|
||||
# fda - including hidden directories
|
||||
fda() {
|
||||
DIR=$(find ${1:-.} -type d 2> /dev/null | fzf) && cd "$DIR"
|
||||
local dir
|
||||
dir=$(find ${1:-.} -type d 2> /dev/null | fzf) && cd "$dir"
|
||||
}
|
||||
|
||||
# fh - repeat history
|
||||
@@ -155,6 +158,22 @@ fh() {
|
||||
fkill() {
|
||||
ps -ef | sed 1d | fzf -m | awk '{print $2}' | xargs kill -${1:-9}
|
||||
}
|
||||
|
||||
# fbr - checkout git branch
|
||||
fbr() {
|
||||
local branches branch
|
||||
branches=$(git branch) &&
|
||||
branch=$(echo "$branches" | fzf +s +m) &&
|
||||
git checkout $(echo "$branch" | sed "s/.* //")
|
||||
}
|
||||
|
||||
# fbr - checkout git commit
|
||||
fco() {
|
||||
local commits commit
|
||||
commits=$(git log --pretty=oneline --abbrev-commit) &&
|
||||
commit=$(echo "$commits" | fzf +s +m -e) &&
|
||||
git checkout $(echo "$commit" | sed "s/ .*//")
|
||||
}
|
||||
```
|
||||
|
||||
Key bindings for command line
|
||||
|
||||
Reference in new issue
Block a user