mirror of https://git.decapod.one/brethil/dotfiles
Compare commits
9 Commits
ee531d18cd
...
c41a91e784
Author | SHA1 | Date |
---|---|---|
bretello | c41a91e784 | |
bretello | a20bffdf67 | |
bretello | 1537ddcc64 | |
bretello | aaea49ecf8 | |
bretello | 41eb8f1a5f | |
bretello | f4e960be35 | |
bretello | 58201b2ab7 | |
bretello | 4d9462239f | |
bretello | c329308759 |
|
@ -79,3 +79,5 @@ alias dst='dvc status'
|
||||||
alias dstc='dvc status --cloud'
|
alias dstc='dvc status --cloud'
|
||||||
alias drp='dvc repro'
|
alias drp='dvc repro'
|
||||||
alias drps='dvc repro -s'
|
alias drps='dvc repro -s'
|
||||||
|
|
||||||
|
alias -g J="| jq "
|
||||||
|
|
|
@ -34,15 +34,8 @@ function git-sort-branch-by-usage(){
|
||||||
function git-switch-recent-branch(){
|
function git-switch-recent-branch(){
|
||||||
git switch $1
|
git switch $1
|
||||||
}
|
}
|
||||||
# compdef git-sort-branch-by-usage git-switch-recent-branch
|
|
||||||
compdef "__git_completion_wrapper __git_recent_branches" 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 showtool $(git log --oneline $@ | fzf --multi --preview 'git -p show --color=always {+1}' --preview-window=right,60% | awk '{print $1}')
|
|
||||||
}
|
|
||||||
compdef _git fgitlog=git-log
|
|
||||||
|
|
||||||
function git-commit-show() {
|
function 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 \
|
fzf --ansi --no-sort --reverse --tiebreak=index --preview \
|
||||||
|
@ -87,18 +80,26 @@ function gco() {
|
||||||
if [[ "$#" -ge 1 ]]; then
|
if [[ "$#" -ge 1 ]]; then
|
||||||
g checkout $@
|
g checkout $@
|
||||||
elif [[ "$#" -eq 0 ]]; then
|
elif [[ "$#" -eq 0 ]]; then
|
||||||
g checkout $(gb | fzf)
|
local selected
|
||||||
|
selected=$(git branch --format "%(refname)" | cut -d / -f 3- | fzf)
|
||||||
|
if [[ -n $selected ]]; then
|
||||||
|
git checkout "$selected"
|
||||||
|
else
|
||||||
|
echo "Nothing selected"
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
compdef "__git_completion_wrapper _git-checkout" gco
|
||||||
|
|
||||||
|
|
||||||
_disable_alias gcor
|
_disable_alias gcor
|
||||||
function gcor() {
|
function gcor() {
|
||||||
if [[ "$#" -ge 1 ]]; then
|
if [[ "$#" -ge 1 ]]; then
|
||||||
g checkout $@
|
git checkout $@
|
||||||
elif [[ "$#" -eq 0 ]]; then
|
elif [[ "$#" -eq 0 ]]; then
|
||||||
g checkout --track $(gbr | fzf)
|
git checkout --track $(gbr | fzf)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -116,9 +117,9 @@ compdef "__git_completion_wrapper __git_recent_branches" gbd
|
||||||
_disable_alias gbD
|
_disable_alias gbD
|
||||||
function gbD() {
|
function gbD() {
|
||||||
if [[ "$#" -ge 1 ]]; then
|
if [[ "$#" -ge 1 ]]; then
|
||||||
g branch -D $@
|
git branch -D $@
|
||||||
elif [[ "$#" -eq 0 ]]; then
|
elif [[ "$#" -eq 0 ]]; then
|
||||||
g branch -D $(gb | fzf -m)
|
git branch -D $(git branch | fzf -m)
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
compdef "__git_completion_wrapper __git_recent_branches" gbD
|
compdef "__git_completion_wrapper __git_recent_branches" gbD
|
||||||
|
|
|
@ -224,7 +224,7 @@ __completion_wrapper(){
|
||||||
# completion functions
|
# completion functions
|
||||||
local _completion_function=$1
|
local _completion_function=$1
|
||||||
local _completion_base=$2
|
local _completion_base=$2
|
||||||
if ! command -v $_completion_function; then
|
if ! command -v $_completion_function &>/dev/null; then
|
||||||
$_completion_base
|
$_completion_base
|
||||||
fi
|
fi
|
||||||
$_completion_function
|
$_completion_function
|
||||||
|
|
|
@ -1,25 +1,52 @@
|
||||||
mkvenv(){
|
mkvenv(){
|
||||||
local source_venv
|
local source_venv force_create venv_name
|
||||||
if [[ $1 == "-s" ]]; then
|
while getopts "sf" opt; do
|
||||||
source_venv=y
|
case $opt in
|
||||||
|
s|source) source_venv=y ;;
|
||||||
|
f|force) force_create=y ;;
|
||||||
|
*) echo "Unknown option: $opt"; return 1 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
shift $(($OPTIND-1))
|
||||||
|
if [[ -n $1 ]]; then
|
||||||
|
venv_name=$1
|
||||||
shift
|
shift
|
||||||
|
else
|
||||||
|
venv_name=.venv
|
||||||
fi
|
fi
|
||||||
# any arguments are passed on to the `venv` module as flags/arguments
|
# any other arguments are passed on to the `venv` module as flags/arguments
|
||||||
if [[ -e .venv ]]; then
|
|
||||||
echo "$(color $RED Error:) $(color $BOLD .venv) already exists." >&2
|
|
||||||
|
if [[ -e ${venv_name} ]]; then
|
||||||
|
if [[ -n ${force_create} ]]; then
|
||||||
|
if [[ -n $VIRTUAL_ENV ]]; then # deactivate venv if enabled
|
||||||
|
deactivate && warning "Deactivated existing virtualenv" || red "Could not run deactivate";
|
||||||
|
fi
|
||||||
|
rm -rf ${venv_name} && warning "Deleted existing virtualenv."
|
||||||
|
else
|
||||||
|
error "$(color $BOLD .venv) already exists. Run with -f to recreate it." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
info "Creating virtualenv ${venv_name}... "
|
||||||
|
|
||||||
|
if ! python -m virtualenv $@ ${venv_name} ; then
|
||||||
|
error "Failed to create virtualenv. Is virtualenv installed? Try:\n $ pip install virtualenv"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -n "Creating venv..." && python -m virtualenv $@ .venv || echo -e "Failed to create virtualenv. Is virtualenv installed? Try:\n $ pip install virtualenv"
|
|
||||||
if [[ -z ${source_venv} ]]; then
|
if [[ -z ${source_venv} ]]; then
|
||||||
echo -n " done. Enable? [Y/n]"
|
echo -n " done. Enable? [Y/n] "
|
||||||
read source_venv
|
read source_venv
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $source_venv != "n" ]]; then
|
if [[ $source_venv != "n" ]]; then
|
||||||
source .venv/bin/activate && echo -e " → $(color $BOLD Enabled!) 🐍 $(color $BOLD$PURPLE $(python --version | cut -d " " -f2 )) ($(color $BOLD$GREEN $(pip --version | cut -d " " -f -2)))"
|
source ${venv_name}/bin/activate && \
|
||||||
|
echo -e " → $(color $BOLD Enabled!) 🐍 $(color $BOLD$PURPLE $(python --version | cut -d " " -f2 )) ($(color $BOLD$GREEN $(pip --version | cut -d " " -f -2)))"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,5 +6,13 @@ vimscratch() {
|
||||||
if [ ! -t 0 ] ; then
|
if [ ! -t 0 ] ; then
|
||||||
stdin_arg="-"
|
stdin_arg="-"
|
||||||
fi
|
fi
|
||||||
vim -c "set buftype=nofile" $@ $stdin_arg
|
set +x
|
||||||
|
if [[ -n "$1" ]]; then
|
||||||
|
filetype=$1
|
||||||
|
shift
|
||||||
|
vim -c "set buftype=nofile" -c "set filetype=$filetype" $@ $stdin_arg
|
||||||
|
else
|
||||||
|
vim -c "set buftype=nofile" $filetype_arg $@ $stdin_arg
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,3 +35,4 @@ abbrevcommit = true
|
||||||
[alias]
|
[alias]
|
||||||
showtool = "!showci () { rev=${1:-HEAD}; git difftool $rev~1 $rev; }; showci $1"
|
showtool = "!showci () { rev=${1:-HEAD}; git difftool $rev~1 $rev; }; showci $1"
|
||||||
mylog = "log --pretty='format:👉 %C(yellow)commit: %h%C(auto)%d %Creset%nAuthor: %C(auto,cyan)%>(12)%an (%aE)%n%C(reset)Date: %C(auto,green)%ar%Creset%nContent: %s'"
|
mylog = "log --pretty='format:👉 %C(yellow)commit: %h%C(auto)%d %Creset%nAuthor: %C(auto,cyan)%>(12)%an (%aE)%n%C(reset)Date: %C(auto,green)%ar%Creset%nContent: %s'"
|
||||||
|
flog = "!flog() { git log --oneline $@ | fzf --multi --preview 'git -p show --color=always {+1}' --preview-window=right,60% | awk '{print $1}'; }; flog"
|
||||||
|
|
|
@ -32,6 +32,11 @@ nmap <C-W>n :tabnext<CR>
|
||||||
nmap <C-W>p :tabprev<CR>
|
nmap <C-W>p :tabprev<CR>
|
||||||
nmap <C-W>N :tabnew<CR>
|
nmap <C-W>N :tabnew<CR>
|
||||||
|
|
||||||
|
" move betweween methods, centering the method on each movement
|
||||||
|
" [m moves to the start of the previous method, ]m to the end
|
||||||
|
map <Leader>] ]mzz
|
||||||
|
map <Leader>[ [mzz
|
||||||
|
|
||||||
" open quickfix
|
" open quickfix
|
||||||
nmap <leader>cc :botright cope<CR>
|
nmap <leader>cc :botright cope<CR>
|
||||||
" open loclist
|
" open loclist
|
||||||
|
|
|
@ -66,6 +66,9 @@ set cursorline
|
||||||
" Minimum fold size
|
" Minimum fold size
|
||||||
set foldminlines=3
|
set foldminlines=3
|
||||||
|
|
||||||
|
" Timeout for combined keymaps (half a sec)
|
||||||
|
set timeoutlen=500
|
||||||
|
|
||||||
autocmd FileType qf,ll setlocal wrap "quickfix,loclist
|
autocmd FileType qf,ll setlocal wrap "quickfix,loclist
|
||||||
autocmd FileType markdown setlocal wrap spell spelllang=it,en
|
autocmd FileType markdown setlocal wrap spell spelllang=it,en
|
||||||
autocmd FileType yaml,yml setlocal shiftwidth=2 softtabstop=2 expandtab
|
autocmd FileType yaml,yml setlocal shiftwidth=2 softtabstop=2 expandtab
|
||||||
|
|
Loading…
Reference in New Issue