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
|
```sh
|
||||||
# vimf - Open selected file in Vim
|
# vimf - Open selected file in Vim
|
||||||
vimf() {
|
vimf() {
|
||||||
FILE=$(fzf) && vim "$FILE"
|
local file
|
||||||
|
file=$(fzf) && vim "$file"
|
||||||
}
|
}
|
||||||
|
|
||||||
# fd - cd to selected directory
|
# fd - cd to selected directory
|
||||||
fd() {
|
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 - including hidden directories
|
||||||
fda() {
|
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
|
# fh - repeat history
|
||||||
@ -155,6 +158,22 @@ fh() {
|
|||||||
fkill() {
|
fkill() {
|
||||||
ps -ef | sed 1d | fzf -m | awk '{print $2}' | xargs kill -${1:-9}
|
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
|
Key bindings for command line
|
||||||
|
3
install
3
install
@ -111,7 +111,8 @@ __fsel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
__fcd() {
|
__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
|
if [ -z "$(set -o | grep '^vi.*on')" ]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user