integration of tmux and vim, updated install.sh

This commit is contained in:
ADRN 2023-11-17 01:22:32 +01:00
parent 928fa7b4b0
commit 81a05a63e0
6 changed files with 223 additions and 120 deletions

3
.gitmodules vendored
View file

@ -28,3 +28,6 @@
[submodule "vim/bundle/vim-nix"] [submodule "vim/bundle/vim-nix"]
path = vim/bundle/vim-nix path = vim/bundle/vim-nix
url = git@github.com:LnL7/vim-nix.git url = git@github.com:LnL7/vim-nix.git
[submodule "prive"]
path = dotfiles_private
url = git@git.deuxfleurs.fr:adrien/dotfiles_private.git

1
dotfiles_private Submodule

@ -0,0 +1 @@
Subproject commit a27488549dedf528406d4b41c35bf0708b0aa242

View file

@ -1,111 +1,146 @@
#!/bin/bash #!/usr/bin/env bash
# Adrien Luxey - Feb. 2019 # Adrien Luxey - Feb. 2019
# Script inspired by https://github.com/mathiasbynens/dotfiles/blob/master/bootstrap.sh # Script inspired by https://github.com/mathiasbynens/dotfiles/blob/master/bootstrap.sh
# Get dotfiles dir # Get dotfiles dir
DOTDIR=$(cd "$(dirname ${BASH_SOURCE})"; pwd) DOTDIR=$(cd "$(dirname ${BASH_SOURCE})"; pwd)
INSTALLED_FLAG_FILE="$DOTDIR/.installed" PRIVATE_DOTFILES_DIR=""
INSTALL_SUBLIME=0 INSTALLED_FLAG_FILE="${DOTDIR}/.installed"
SUBLIME=0
INSTALL=0
function main {
parseArgs $@
# Do the things
if [[ ${INSTALL} -eq 1 ]]; then
if [ ! -f ${INSTALLED_FLAG_FILE} ]; then
echo "Stuff seems already installed. Remove \`.installed\` if this is false."
else
installDependencies && touch ${INSTALLED_FLAG_FILE}
fi
fi
setupDotfiles
echo "All done!"
exit 0
}
function printHelp { function printHelp {
cat <<-EOF cat <<-EOF
USAGE: $0 [OPTIONS] USAGE: $0 [OPTIONS]
OPTIONS: OPTIONS:
-s|--sublime Install Sublime Text 3 -i|--install Install software for Debian (incl. Tmux & vim but not Sublime Text)
-s|--sublime Install & Configure Sublime Text 3 for Debian
-h|--help Show this help -h|--help Show this help
The script will install dependencies once (remove ${INSTALLED_FLAG_FILE} to redo) and symlink dotfiles to their destination in your \$HOME. Sets up dotfiles,
The script will install dependencies once (remove ${INSTALLED_FLAG_FILE} to redo) and symlink dotfiles to their destination in your \${HOME}.
EOF EOF
exit $1; exit $1;
} }
function syncDotfiles { function parseArgs {
echo Removing previous dotfiles... while (( "$#" )); do
rm $HOME/.zshrc > /dev/null 2>&1 case "$1" in
rm $HOME/.vimrc > /dev/null 2>&1 -h|--help)
rm $HOME/.tmux.conf > /dev/null 2>&1 printHelp 0
rm -rf $HOME/.vim > /dev/null 2>&1 shift
rm -rf $HOME/.tmux > /dev/null 2>&1 ;;
rm $HOME/.ssh/config > /dev/null 2>&1 -s|--sublime)
SUBLIME=1
shift
;;
-i|--install)
INSTALL=1
shift
;;
--)
shift
break
;;
-*|--*=)
echo "Error: Unsupported flag $1" >&2
printHelp 1
;;
esac
done
}
echo Installing our dotfiles... function setupDotfiles {
ln -s $DOTDIR/zshrc $HOME/.zshrc read -p "Will now remove previous dotfiles. Ready?" -n 1 -r
ln -s $DOTDIR/vimrc $HOME/.vimrc
ln -s $DOTDIR/tmux.conf $HOME/.tmux.conf rm ${HOME}/.zshrc > /dev/null 2>&1
ln -s $DOTDIR/vim $HOME/.vim rm ${HOME}/.vimrc > /dev/null 2>&1
ln -s $DOTDIR/tmux $HOME/.tmux rm ${HOME}/.tmux.conf > /dev/null 2>&1
if [ -d "$HOME/.config/sublime-text-3" ]; then rm -rf ${HOME}/.vim > /dev/null 2>&1
rm -rf $HOME/.config/sublime-text-3/Packages/User > /dev/null 2>&1 rm -rf ${HOME}/.tmux > /dev/null 2>&1
ln -s $DOTDIR/sublime $HOME/.config/sublime-text-3/Packages/User rm ${HOME}/.ssh/config > /dev/null 2>&1
elif [ -d "$HOME/.config/sublime-text" ]; then
rm -rf $HOME/.config/sublime-text/Packages/User > /dev/null 2>&1 echo Setting up dotfiles...
ln -s $DOTDIR/sublime $HOME/.config/sublime-text/Packages/User ln -s ${DOTDIR}/zshrc ${HOME}/.zshrc
ln -s ${DOTDIR}/vimrc ${HOME}/.vimrc
ln -s ${DOTDIR}/tmux.conf ${HOME}/.tmux.conf
ln -s ${DOTDIR}/vim ${HOME}/.vim
ln -s ${DOTDIR}/tmux ${HOME}/.tmux
mkdir -p ${HOME}/.ssh
ln -s ${DOTDIR}/dotfiles_private/ssh_config ~/.ssh/config
# Setup Sublime Text
if [[ ${SUBLIME} -eq 1 ]]; then
echo
if [ -d "${HOME}/.config/sublime-text-3" ]; then
rm -rf ${HOME}/.config/sublime-text-3/Packages/User > /dev/null 2>&1
ln -s ${DOTDIR}/sublime ${HOME}/.config/sublime-text-3/Packages/User
elif [ -d "${HOME}/.config/sublime-text" ]; then
rm -rf ${HOME}/.config/sublime-text/Packages/User > /dev/null 2>&1
ln -s ${DOTDIR}/sublime ${HOME}/.config/sublime-text/Packages/User
fi
fi fi
mkdir -p $HOME/.ssh
ln -s $DOTDIT/ssh_config ~/.ssh/config
} }
function installDependencies { function installDependencies {
echo Installing dependencies... read -p "Will now install apt dependencies, OhMyZSH (wget | sh) and sub-repos. Ready?" -n 1 -r
# Dependencies # Dependencies
sudo apt update > /dev/null 2>&1 sudo apt update > /dev/null 2>&1
sudo apt install -y apt-transport-https curl zsh tmux autojump fonts-firacode fonts-powerline > /dev/null 2>&1 sudo apt install -y apt-transport-https curl zsh tmux autojump \
fonts-firacode fonts-powerline > /dev/null 2>&1
# Install Sublime Text # Install Sublime Text
if [[ ${INSTALL_SUBLIME} -eq 1 ]]; then if [[ ${SUBLIME} -eq 1 ]]; then
echo Installing Sublime Text 3... echo Installing Sublime Text 3...
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add - > /dev/null 2>&1 wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | \
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list > /dev/null 2>&1 gpg --dearmor | \
#sudo apt update > /dev/null 2>&1 sudo tee /etc/apt/trusted.gpg.d/sublimehq-archive.gpg > /dev/null
echo "deb https://download.sublimetext.com/ apt/stable/" | \
sudo tee /etc/apt/sources.list.d/sublime-text.list > /dev/null 2>&1
sudo apt update > /dev/null 2>&1
sudo apt install sublime-text -y > /dev/null 2>&1 sudo apt install sublime-text -y > /dev/null 2>&1
fi fi
# Install Oh My Zsh # Install Oh My Zsh
if [ ! -d "$HOME/.oh-my-zsh" ]; then if [ ! -d "${HOME}/.oh-my-zsh" ]; then
echo Installing Oh-My-Zsh... echo Installing Oh-My-Zsh...
sh -c "$(wget -q https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" sh -c "$(wget -q https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
# Install powerlevel9k theme in Oh-My-Zsh # Install powerlevel9k theme in Oh-My-Zsh
if [ ! -d "$HOME/.oh-my-zsh/custom/themes/powerlevel9k" ]; then if [ ! -d "${HOME}/.oh-my-zsh/custom/themes/powerlevel9k" ]; then
echo Installing Powerlevel9k theme... echo Installing Powerlevel9k theme...
git clone https://github.com/bhilburn/powerlevel9k.git $HOME/.oh-my-zsh/custom/themes/powerlevel9k > /dev/null 2>&1 git clone https://github.com/bhilburn/powerlevel9k.git \
${HOME}/.oh-my-zsh/custom/themes/powerlevel9k > /dev/null 2>&1
fi fi
fi fi
echo "Pulling git submodules..." read -p "Adding adrien/dotfiles_private submodule... Ready?" -n 1 -r
cd $DOTDIR && (git submodule update --init >> /dev/null 2>&1) || echo "'git submobule update --init' failed, is your SSH key available on GitHub?" && exit -1; git submodule add --name prive git@git.deuxfleurs.fr:adrien/dotfiles_private.git prive
echo Pulling git submodules...
cd ${DOTDIR} && (git submodule update --init >> /dev/null 2>&1) || \
echo "'git submobule update --init' failed, is your SSH key available on GitHub?" && exit -1;
# Make ZSH is the current SHELL # Make ZSH is the current SHELL
echo $SHELL | grep zsh > /dev/null || chsh -s $(which zsh) echo $SHELL | grep zsh > /dev/null || chsh -s $(which zsh)
} }
# Parse command-line arguments main $@
while (( "$#" )); do
case "$1" in
-h|--help)
printHelp 0
;;
-s|--sublime)
INSTALL_SUBLIME=1
shift
;;
--)
shift
break
;;
-*|--*=)
echo "Error: Unsupported flag $1" >&2
printHelp 1
;;
esac
done
if [ ! -f $INSTALLED_FLAG_FILE ]; then
installDependencies && touch $INSTALLED_FLAG_FILE
fi
syncDotfiles
echo "All done!"
exit 0

View file

@ -1,5 +1,5 @@
# KEY BINDINGS # KEY BINDINGS
# Alex Auvolat + Adrien Luxey additions # Adrien Luxey
########################### ###########################
### Packages management ### ### Packages management ###
@ -78,6 +78,27 @@ bind -T off F10 \
refresh-client -S refresh-client -S
##################################################### #####################################################
# Vim Tmux Navigator
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
#tmux_version='$(tmux -V | sed -En "s/^tmux ([1-9]+(.[0-9]+)?).*/\1/p")'
#if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
# "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
#if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
# "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
#bind-key -T copy-mode-vi 'C-h' select-pane -L
#bind-key -T copy-mode-vi 'C-j' select-pane -D
#bind-key -T copy-mode-vi 'C-k' select-pane -U
#bind-key -T copy-mode-vi 'C-l' select-pane -R
#bind-key -T copy-mode-vi 'C-m' select-pane -l
# Notes : # Notes :
# prefix ~ --> show-messages (see previous messages) # prefix ~ --> show-messages (see previous messages)
@ -116,8 +137,8 @@ bind l select-pane -R
bind k select-pane -U bind k select-pane -U
bind j select-pane -D bind j select-pane -D
# switch windows using bindings C-q C-hl # switch windows using bindings C-q C-hl
unbind ^H #unbind ^H
unbind ^L #unbind ^L
bind ^H previous-window bind ^H previous-window
bind ^L next-window bind ^L next-window

@ -1 +1 @@
Subproject commit 7d23e97d13c40fcc6d603b291fe9b6e5f92516ee Subproject commit 1e8d3cc4d74f40fb384cd1739739543fe117ff61

145
vimrc
View file

@ -11,10 +11,12 @@ call vundle#begin()
" let Vundle manage Vundle, required " let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim' Plugin 'VundleVim/Vundle.vim'
Plugin 'christoomey/vim-tmux-navigator' " Vim Tmux Navigator
Plugin 'vim-airline/vim-airline' " Airline bar Plugin 'vim-airline/vim-airline' " Airline bar
Plugin 'vim-airline/vim-airline-themes' " Airline themes Plugin 'vim-airline/vim-airline-themes' " Airline themes
Plugin 'LnL7/vim-nix' Plugin 'LnL7/vim-nix' " Nix
" Themes " Themes
" Plugin 'arcticicestudio/nord-vim' " Plugin 'arcticicestudio/nord-vim'
@ -27,6 +29,50 @@ filetype plugin indent on " required
" End Vundle config " " End Vundle config "
""""""""""""""""""""" """""""""""""""""""""
""""""""""""""
" Navigation "
""""""""""""""
" navigation between splits
" https://thoughtbot.com/blog/vim-splits-move-faster-and-more-naturally#easier-split-navigations
"nnoremap <C-J> <C-W><C-J>
"nnoremap <C-K> <C-W><C-K>
"nnoremap <C-L> <C-W><C-L>
"nnoremap <C-H> <C-W><C-H>
" From https://stackoverflow.com/questions/33245317/vim-and-azerty-keyboards
" 1. Move to the end of the line
noremap m $
" 2. Search backward for the word under the cursor
noremap µ #
" 3. Navigate to the help tag under the cursor
" noremap ' <C-]>
" Scroller comme un pro
" N'utilise que j et k
" Ctrl-e & Ctrl-y pour scroller dans un document
set scrolloff=12
" Ctrl+W +/-: increase/decrease height (ex. 20<C-w>+)
" Ctrl+W >/<: increase/decrease width (ex. 30<C-w><)
" Ctrl+W =: equalize width and height of all windows
" Ctrl+W _: set height (ex. 50<C-w>_)
" Ctrl+W |: set width (ex. 50<C-w>|)
""""""""""""""""""""
" Tmux integration "
""""""""""""""""""""
" auto-reload tmux conf when updated
autocmd bufwritepost ~/dotfiles/.tmux.conf execute ':!tmux source-file %'
""""""""
" Misc "
""""""""
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
" Styling " Styling
syntax enable syntax enable
@ -42,8 +88,7 @@ set noundofile
" Line numbering (hybrid: relative and absolute) " Line numbering (hybrid: relative and absolute)
set number relativenumber set number relativenumber
augroup numbertoggle augroup numbertoggle autocmd!
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
augroup END augroup END
@ -59,6 +104,52 @@ augroup END
" Adapted from https://github.com/jessfraz/.vim/blob/master/vimrc " " Adapted from https://github.com/jessfraz/.vim/blob/master/vimrc "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ----------------------------------------- "
" File Type settings "
" ----------------------------------------- "
au BufNewFile,BufRead *.vim setlocal noet ts=4 sw=4 sts=4
au BufNewFile,BufRead *.txt setlocal noet ts=4 sw=4
"#au BufNewFile,BufRead *.md setlocal spell noet ts=4 sw=4
au BufNewFile,BufRead *.md setlocal nospell noet ts=4 sw=4
au BufNewFile,BufRead *.yml,*.yaml setlocal expandtab ts=2 sw=2
au BufNewFile,BufRead *.cpp setlocal expandtab ts=2 sw=2
au BufNewFile,BufRead *.hpp setlocal expandtab ts=2 sw=2
au BufNewFile,BufRead *.json setlocal expandtab ts=2 sw=2
au BufNewFile,BufRead *.jade setlocal expandtab ts=2 sw=2
augroup filetypedetect
au BufNewFile,BufRead .tmux.conf*,tmux.conf* setf tmux
au BufNewFile,BufRead .nginx.conf*,nginx.conf* setf nginx
augroup END
au FileType nginx setlocal noet ts=4 sw=4 sts=4
" Go settings
au BufNewFile,BufRead *.go setlocal noet ts=4 sw=4 sts=4
" autocmd BufEnter *.go colorscheme nofrils-dark
" scala settings
autocmd BufNewFile,BufReadPost *.scala setl shiftwidth=2 expandtab
" Markdown Settings
autocmd BufNewFile,BufReadPost *.md setl ts=4 sw=4 sts=4 expandtab
" lua settings
autocmd BufNewFile,BufRead *.lua setlocal noet ts=4 sw=4 sts=4
" Dockerfile settings
autocmd FileType dockerfile set noexpandtab
" shell/config/systemd settings
autocmd FileType fstab,systemd set noexpandtab
autocmd FileType gitconfig,sh,toml set noexpandtab
" python indent
autocmd BufNewFile,BufRead *.py setlocal tabstop=4 softtabstop=4 shiftwidth=4 textwidth=80 smarttab expandtab
"""""""""""""""""""
set splitright " Split vertical windows right to the current windows set splitright " Split vertical windows right to the current windows
set splitbelow " Split horizontal windows below to the current windows set splitbelow " Split horizontal windows below to the current windows
set encoding=utf-8 " Set default encoding to UTF-8 set encoding=utf-8 " Set default encoding to UTF-8
@ -123,54 +214,6 @@ map q: :q
let &t_SI .= "\<Esc>[?2004h" let &t_SI .= "\<Esc>[?2004h"
let &t_EI .= "\<Esc>[?2004l" let &t_EI .= "\<Esc>[?2004l"
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
" ----------------------------------------- "
" File Type settings "
" ----------------------------------------- "
au BufNewFile,BufRead *.vim setlocal noet ts=4 sw=4 sts=4
au BufNewFile,BufRead *.txt setlocal noet ts=4 sw=4
"#au BufNewFile,BufRead *.md setlocal spell noet ts=4 sw=4
au BufNewFile,BufRead *.md setlocal nospell noet ts=4 sw=4
au BufNewFile,BufRead *.yml,*.yaml setlocal expandtab ts=2 sw=2
au BufNewFile,BufRead *.cpp setlocal expandtab ts=2 sw=2
au BufNewFile,BufRead *.hpp setlocal expandtab ts=2 sw=2
au BufNewFile,BufRead *.json setlocal expandtab ts=2 sw=2
au BufNewFile,BufRead *.jade setlocal expandtab ts=2 sw=2
augroup filetypedetect
au BufNewFile,BufRead .tmux.conf*,tmux.conf* setf tmux
au BufNewFile,BufRead .nginx.conf*,nginx.conf* setf nginx
augroup END
au FileType nginx setlocal noet ts=4 sw=4 sts=4
" Go settings
au BufNewFile,BufRead *.go setlocal noet ts=4 sw=4 sts=4
" autocmd BufEnter *.go colorscheme nofrils-dark
" scala settings
autocmd BufNewFile,BufReadPost *.scala setl shiftwidth=2 expandtab
" Markdown Settings
autocmd BufNewFile,BufReadPost *.md setl ts=4 sw=4 sts=4 expandtab
" lua settings
autocmd BufNewFile,BufRead *.lua setlocal noet ts=4 sw=4 sts=4
" Dockerfile settings
autocmd FileType dockerfile set noexpandtab
" shell/config/systemd settings
autocmd FileType fstab,systemd set noexpandtab
autocmd FileType gitconfig,sh,toml set noexpandtab
" python indent
autocmd BufNewFile,BufRead *.py setlocal tabstop=4 softtabstop=4 shiftwidth=4 textwidth=80 smarttab expandtab
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""
" End https://github.com/jessfraz/.vim/blob/master/vimrc " " End https://github.com/jessfraz/.vim/blob/master/vimrc "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""