mirror of
https://git.decapod.one/brethil/dotfiles
synced 2024-11-21 11:01:31 +01:00
zsh: refactor aliases/functions sourcing
This commit is contained in:
parent
9b6494c94d
commit
41b97a1be3
4
aliases/README.md
Normal file
4
aliases/README.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
# aliases
|
||||
|
||||
Place custom alias definitions in this folder, with a `.zsh` extension.
|
||||
These files will be sourced on startup
|
|
@ -87,15 +87,19 @@ alias esource='$EDITOR $HOME/.zshrc'
|
|||
alias resource='source $HOME/.zshrc'
|
||||
alias dotedit='$EDITOR $DOTFILES/brethil_dotfile.sh'
|
||||
# Custom definitions files
|
||||
alias funedit='$EDITOR ~/.dotfiles_functions.sh'
|
||||
alias aledit='$EDITOR ~/.dotfiles_aliases.sh'
|
||||
alias funedit='$EDITOR ~/.dotfiles_functions'
|
||||
alias aledit='$EDITOR ~/.dotfiles_aliases'
|
||||
|
||||
export p="${HOME}/projects"
|
||||
export g="${HOME}/git"
|
||||
export w="${HOME}/work"
|
||||
|
||||
source $DOTFILES/functions.zsh
|
||||
source $DOTFILES/aliases.zsh
|
||||
|
||||
for defname in aliases functions ; do
|
||||
for def in $DOTFILES/$defname/*zsh ; do
|
||||
source $def
|
||||
done
|
||||
done
|
||||
unset def defname
|
||||
|
||||
# Extras
|
||||
functions_file=~/.dotfiles_functions
|
||||
|
|
4
functions/README.md
Normal file
4
functions/README.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
# functions
|
||||
|
||||
Place custom functions definitions in this folder, with a `.zsh` extension.
|
||||
These files will be sourced on startup
|
|
@ -275,6 +275,19 @@ __git_completion_wrapper() {
|
|||
__completion_wrapper $1 _git
|
||||
}
|
||||
|
||||
|
||||
# sort branches by latest commit
|
||||
function git-sort-branch-by-usage(){
|
||||
git for-each-ref --sort=committerdate refs/heads/ --format='%(refname:short)'
|
||||
}
|
||||
|
||||
# switch to a recent branch
|
||||
function git-switch-recent-branch(){
|
||||
git switch $1
|
||||
}
|
||||
# compdef git-sort-branch-by-usage git-switch-recent-branch
|
||||
compdef "__git_completion_wrapper __git_recent_branches" git-switch-recent-branch
|
||||
|
||||
# Runs git log with fzf with preview
|
||||
function fgitlog() {
|
||||
git log --oneline $@ | fzf --multi --preview 'git -p show --color=always {+1}' --preview-window=right,60%
|
||||
|
@ -282,7 +295,7 @@ function fgitlog() {
|
|||
compdef _git fgitlog=git-log
|
||||
|
||||
git-commit-show() {
|
||||
git log --graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr" |
|
||||
git log --graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr" $@ |
|
||||
fzf --ansi --no-sort --reverse --tiebreak=index --preview \
|
||||
'f() {
|
||||
set -- $(echo -- "$@" | grep -o "[a-f0-9]\{7\}")
|
Loading…
Reference in New Issue
Block a user