mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-19 09:03:43 -05:00
Added some handy fzf-related fish functions I use daily at work
@@ -102,9 +102,31 @@ function fco -d "Fuzzy-find and checkout a branch"
|
|||||||
git branch --all | grep -v HEAD | string trim | fzf | read -l result; and git checkout "$result"
|
git branch --all | grep -v HEAD | string trim | fzf | read -l result; and git checkout "$result"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function fco -d "Fuzzy-find and checkout a branch (alternate method)"
|
||||||
|
git for-each-ref --format='%(refname:short)' refs/heads | fzf --height 10% --layout=reverse --border | xargs git checkout
|
||||||
|
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;}' | read -l result; and git checkout "$result"
|
git log --pretty=oneline --abbrev-commit --reverse | fzf --tac +s -e | awk '{print $1;}' | read -l result; and git checkout "$result"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function snag -d "Pick desired files from a chosen branch"
|
||||||
|
# use fzf to choose source branch to snag files FROM
|
||||||
|
set branch (git for-each-ref --format='%(refname:short)' refs/heads | fzf --height 10% --layout=reverse --border)
|
||||||
|
# use fzf to choose files that differ from current branch
|
||||||
|
set files (git diff --name-only $branch | fzf --height 10% --layout=reverse --border --multi)
|
||||||
|
# avoid checking out branch if files aren't specified
|
||||||
|
if set -q files
|
||||||
|
git checkout $branch $files
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function fzum -d "View all unmerged commits across all local branches"
|
||||||
|
set viewUnmergedCommits "echo {} | head -1 | xargs -I BRANCH sh -c 'git log master..BRANCH --no-merges --color --format=\"%C(auto)%h - %C(green)%ad%Creset - %s\" --date=format:\'%b %d %Y\''"
|
||||||
|
|
||||||
|
git branch --no-merged master --format "%(refname:short)" | fzf --no-sort --reverse --tiebreak=index --no-multi \
|
||||||
|
--ansi --preview="$viewUnmergedCommits"
|
||||||
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
### SSH
|
### SSH
|
||||||
|
|||||||
Reference in New Issue
Block a user