mirror of
https://github.com/ViViDboarder/shoestrap.git
synced 2024-11-22 07:36:31 +00:00
Add tmux improvements for version testing
This commit is contained in:
parent
70f5fe4ffe
commit
0363735939
@ -10,3 +10,4 @@ alias tiga='tig --all'
|
|||||||
# cd
|
# cd
|
||||||
alias cd..='cd ..'
|
alias cd..='cd ..'
|
||||||
|
|
||||||
|
source $HOME/.bash_funcs
|
||||||
|
60
assets/default/dotfiles/bash_funcs
Normal file
60
assets/default/dotfiles/bash_funcs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
# Version compare based on
|
||||||
|
# http://stackoverflow.com/questions/4023830/bash-how-compare-two-strings-in-version-format
|
||||||
|
vercomp() {
|
||||||
|
if [[ $1 == $2 ]]
|
||||||
|
then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
local IFS=.
|
||||||
|
local i ver1=($1) ver2=($2)
|
||||||
|
# fill empty fields in ver1 with zeros
|
||||||
|
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
|
||||||
|
do
|
||||||
|
ver1[i]=0
|
||||||
|
done
|
||||||
|
for ((i=0; i<${#ver1[@]}; i++))
|
||||||
|
do
|
||||||
|
if [[ -z ${ver2[i]} ]]
|
||||||
|
then
|
||||||
|
# fill empty fields in ver2 with zeros
|
||||||
|
ver2[i]=0
|
||||||
|
fi
|
||||||
|
if ((10#${ver1[i]} > 10#${ver2[i]}))
|
||||||
|
then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if ((10#${ver1[i]} < 10#${ver2[i]}))
|
||||||
|
then
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
vertest() {
|
||||||
|
local ver1=($1) op=($2) ver2=($3)
|
||||||
|
vercomp $ver1 $ver2
|
||||||
|
case $op in
|
||||||
|
'=')
|
||||||
|
[ $? -eq 0 ] && return 0 || return 1
|
||||||
|
;;
|
||||||
|
'!=')
|
||||||
|
[ $? -ne 0 ] && return 0 || return 1
|
||||||
|
;;
|
||||||
|
'<')
|
||||||
|
[ $? -eq 2 ] && return 0 || return 1
|
||||||
|
;;
|
||||||
|
'<=')
|
||||||
|
[ $? -eq 2 -o $? -eq 0 ] && return 0 || return 1
|
||||||
|
;;
|
||||||
|
'>')
|
||||||
|
[ $? -eq 1 ] && return 0 || return 1
|
||||||
|
;;
|
||||||
|
'>=')
|
||||||
|
[ $? -eq 1 -o $? -eq 0 ] && return 0 || return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
return -1
|
||||||
|
}
|
@ -27,9 +27,13 @@ setw -g mouse-select-window on
|
|||||||
setw -g mouse-select-pane on
|
setw -g mouse-select-pane on
|
||||||
|
|
||||||
# easy splitting
|
# easy splitting
|
||||||
bind | split-window -h -c "#{pane_current_path}"
|
if-shell "vertest `tmux -V` '>=' 1.9" 'bind | split-window -h -c "#{pane_current_path}"'
|
||||||
bind - split-window -c "#{pane_current_path}"
|
if-shell "vertest `tmux -V` '>=' 1.9" 'bind - split-window -c "#{pane_current_path}"'
|
||||||
bind _ split-window -c "#{pane_current_path}"
|
if-shell "vertest `tmux -V` '>=' 1.9" 'bind _ split-window -c "#{pane_current_path}"'
|
||||||
|
# old versions
|
||||||
|
if-shell "vertest `tmux -V` '<' 1.9" 'bind | split-window -h'
|
||||||
|
if-shell "vertest `tmux -V` '<' 1.9" 'bind - split-window'
|
||||||
|
if-shell "vertest `tmux -V` '<' 1.9" 'bind _ split-window'
|
||||||
|
|
||||||
# act like vim
|
# act like vim
|
||||||
setw -g mode-keys vi
|
setw -g mode-keys vi
|
||||||
|
@ -10,3 +10,4 @@ try_link "tmux.conf" "$HOME/.tmux.conf"
|
|||||||
source_dotfile "bashrc"
|
source_dotfile "bashrc"
|
||||||
source_dotfile "bash_profile"
|
source_dotfile "bash_profile"
|
||||||
source_dotfile "bash_alias"
|
source_dotfile "bash_alias"
|
||||||
|
source_dotfile "bash_funcs"
|
||||||
|
Loading…
Reference in New Issue
Block a user