Update README and install script
- Added examples: fbr and fco - Always use local variables
This commit is contained in:
parent
c6acb2a639
commit
f4c5aa03d7
25
README.md
25
README.md
@ -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
|
||||
|
3
install
3
install
@ -111,7 +111,8 @@ __fsel() {
|
||||
}
|
||||
|
||||
__fcd() {
|
||||
DIR=$(find ${1:-*} -path '*/\.*' -prune -o -type d -print 2> /dev/null | fzf) && printf 'cd %q' "$DIR"
|
||||
local dir
|
||||
dir=$(find ${1:-*} -path '*/\.*' -prune -o -type d -print 2> /dev/null | fzf) && printf 'cd %q' "$dir"
|
||||
}
|
||||
|
||||
if [ -z "$(set -o | grep '^vi.*on')" ]; then
|
||||
|
Loading…
x
Reference in New Issue
Block a user