From a9ec40568f328a39f63f0959b21ac013255b1848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gremaud?= Date: Fri, 5 May 2023 10:23:40 +0200 Subject: [PATCH 1/4] Add Tmux-sessionizer, tmux-cht, tmux conf and alias for nvim --- scripts/tmux-cht.sh | 14 ++++++++++++++ scripts/tmux-sessionizer | 26 ++++++++++++++++++++++++++ tmux.conf | 7 ++++++- zsh/alias.sh | 1 + 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100755 scripts/tmux-cht.sh create mode 100755 scripts/tmux-sessionizer diff --git a/scripts/tmux-cht.sh b/scripts/tmux-cht.sh new file mode 100755 index 0000000..d639c24 --- /dev/null +++ b/scripts/tmux-cht.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +selected=`cat ~/.tmux-cht-languages ~/.tmux-cht-command | fzf` +if [[ -z $selected ]]; then + exit 0 +fi + +read -p "Enter Query: " query + +if grep -qs "$selected" ~/.tmux-cht-languages; then + query=`echo $query | tr ' ' '+'` + tmux neww bash -c "echo \"curl cht.sh/$selected/$query/\" & curl cht.sh/$selected/$query & while [ : ]; do sleep 1; done" +else + tmux neww bash -c "curl -s cht.sh/$selected~$query | less" +fi diff --git a/scripts/tmux-sessionizer b/scripts/tmux-sessionizer new file mode 100755 index 0000000..ddbaf6c --- /dev/null +++ b/scripts/tmux-sessionizer @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +if [[ $# -eq 1 ]]; then + selected=$1 +else + selected=$(find ~/Documents/Arcanite/ ~/Documents/PolyLAN/ ~/Documents/ -mindepth 1 -maxdepth 1 -type d | fzf) +fi + +if [[ -z $selected ]]; then + exit 0 +fi + +selected_name=$(basename "$selected" | tr . _) +tmux_running=$(pgrep tmux) + +if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then + tmux new-session -s $selected_name -c $selected + exit 0 +fi + +if ! tmux has-session -t=$selected_name 2> /dev/null; then + tmux new-session -ds $selected_name -c $selected +fi + +tmux switch-client -t $selected_name + diff --git a/tmux.conf b/tmux.conf index b6b95d8..61995b8 100644 --- a/tmux.conf +++ b/tmux.conf @@ -19,7 +19,9 @@ bind -n M-d select-pane -R # reload conf bind r source-file ~/.tmux.conf -setw -g mode-keys vi +set-window-option -g mode-keys vi +bind -T copy-mode-vi v send-keys -X begin-selection +bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard' # change color #set -g pane-border-style 'fg=#660033' @@ -54,3 +56,6 @@ run -b '~/.tmux/plugins/tpm/tpm' set -s escape-time 0 set-option -g default-terminal "screen-256color" + +bind-key -r f run-shell "tmux neww ~/Documents/dotfiles/scripts/tmux-sessionizer" +bind-key -r i run-shell "tmux neww tmux-cht.sh" diff --git a/zsh/alias.sh b/zsh/alias.sh index 9510a60..117a50b 100644 --- a/zsh/alias.sh +++ b/zsh/alias.sh @@ -12,6 +12,7 @@ alias mg='python manage.py migrate' alias gp='git push' alias ga!='git commit --amend --no-edit --date now' +alias n='cd . && nvim -S' alias v='nvim' alias vi='nvim' alias vim='nvim' From 0698c60a3d9f053176177f19a9ddc1e541db0c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gremaud?= Date: Wed, 24 May 2023 13:35:32 +0200 Subject: [PATCH 2/4] Update --- config/i3/config | 2 +- config/i3/i3status.conf | 2 +- config/trizen/trizen | 1 + gitignore_global | 1 + nvim/lua/telescope/custom.lua | 4 +- scripts/tmux-sessionizer | 2 +- vimrc | 72 ++++++++++++++++++++++++++--------- zsh/alias.sh | 5 ++- 8 files changed, 65 insertions(+), 24 deletions(-) create mode 120000 config/trizen/trizen diff --git a/config/i3/config b/config/i3/config index 4075ad5..480478b 100644 --- a/config/i3/config +++ b/config/i3/config @@ -303,7 +303,7 @@ bar { status_command py3status position top - tray_output DisplayPort-2 + tray_output primary colors { background #000000 diff --git a/config/i3/i3status.conf b/config/i3/i3status.conf index 995360b..9bc15c2 100644 --- a/config/i3/i3status.conf +++ b/config/i3/i3status.conf @@ -9,7 +9,7 @@ order += "wireless _first_" order += "ethernet _first_" order += net_rate # order += net_iplist -# order += "battery all" +order += "battery all" order += "disk /" order += "disk /home" order += sysdata diff --git a/config/trizen/trizen b/config/trizen/trizen new file mode 120000 index 0000000..7e85c82 --- /dev/null +++ b/config/trizen/trizen @@ -0,0 +1 @@ +/home/legrems/Documents/dotfiles/config/trizen \ No newline at end of file diff --git a/gitignore_global b/gitignore_global index 72a5320..9cbb660 100644 --- a/gitignore_global +++ b/gitignore_global @@ -2,3 +2,4 @@ .autoenv_leave.zsh tags Session.vim +*.rest diff --git a/nvim/lua/telescope/custom.lua b/nvim/lua/telescope/custom.lua index 633ac21..90f961b 100644 --- a/nvim/lua/telescope/custom.lua +++ b/nvim/lua/telescope/custom.lua @@ -19,7 +19,7 @@ require("telescope").setup{ mappings = { i = { [""] = actions.close, - [""] = false + [""] = false, }, }, theme = "ivy", @@ -28,7 +28,7 @@ require("telescope").setup{ git_branches = { mappings = { i = { - [""] = interactive_rebase + [""] = interactive_rebase, }, }, }, diff --git a/scripts/tmux-sessionizer b/scripts/tmux-sessionizer index ddbaf6c..6fdb71f 100755 --- a/scripts/tmux-sessionizer +++ b/scripts/tmux-sessionizer @@ -3,7 +3,7 @@ if [[ $# -eq 1 ]]; then selected=$1 else - selected=$(find ~/Documents/Arcanite/ ~/Documents/PolyLAN/ ~/Documents/ -mindepth 1 -maxdepth 1 -type d | fzf) + selected=$(find ~/Documents/Arcanite/ ~/Documents/PolyLAN/ ~/Documents/Python ~/Documents/ -mindepth 1 -maxdepth 1 -type d | fzf) fi if [[ -z $selected ]]; then diff --git a/vimrc b/vimrc index 2b375ae..7e2a401 100644 --- a/vimrc +++ b/vimrc @@ -40,7 +40,7 @@ set shell=bash " http://www.shallowsky.com/linux/noaltscreen.html set t_ti= t_te= " keep more context when scrolling off the end of a buffer -set scrolloff=3 +set scrolloff=15 " Store temporary files in a central spot set backup set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp @@ -79,7 +79,7 @@ augroup vimrcEx \ endif "for ruby, autoindent with two spaces, always expand tabs - autocmd FileType ruby,haml,eruby,yaml,html,javascript,sass,cucumber set ai sw=2 sts=2 et + autocmd FileType ruby,haml,eruby,yaml,html,htmldjango,javascript,sass,cucumber set ai sw=4 sts=4 et autocmd FileType python set sw=4 sts=4 et autocmd! BufRead,BufNewFile *.sass setfiletype sass @@ -118,6 +118,11 @@ imap " Clear the search buffer when hitting return nnoremap +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" MISC COMMANDS +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +cmap w!! w !sudo tee % > /dev/null + """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " MULTIPURPOSE TAB KEY " Indent if we're at the beginning of a line. Else, do completion. @@ -145,33 +150,39 @@ map v :view %% """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " RENAME CURRENT FILE """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -function! RenameFile() +function! RenameFile() let old_name = expand('%') - let new_name = input('New file name: ', expand('%'), 'file') + let new_name = input('New file name: ', expand('%:.:h') . '/') if new_name != '' && new_name != old_name exec ':saveas ' . new_name exec ':silent !rm ' . old_name redraw! endif endfunction -map n :call RenameFile() +map m :call RenameFile() -function! RandomHexString(...) - let random_string = system('cat /dev/urandom | tr -dc "0-9a-f" | head -c '.shellescape(a)) +function! RandomHexString() + let string_length = input('String length: ') + let random_string = system('cat /dev/urandom | tr -dc "0-9a-f" | head -c '.shellescape(string_length)) + + call setline(line('.'), getline('.') . random_string) return random_string endfunction -function! RandomString(...) - let random_string = system('cat /dev/urandom | tr -dc "0-9A-z" | head -c '.shellescape(a)) +function! RandomString() + let string_length = input('String length: ') + let random_string = system('cat /dev/urandom | tr -dc "0-9A-z" | head -c '.shellescape(string_length)) + + call setline(line('.'), getline('.') . random_string) return random_string endfunction -command! -range Md5 :echo system('echo '.shellescape(join(getline(, ), '\n')) . '| md5sum') +map rhs :call RandomHexString() +map rs :call RandomString() -command! -nargs=1 RandomHexString :normal a=RandomHexString() -command! -nargs=1 RandomString :normal a=RandomString() +command! -range Sha :call append(line('.'), system('echo '.shellescape(join(getline(, ), '\n')) . "| sha1sum | awk '{print $1}'")) -command! InsertTime :normal a=strftime('%F %H:%M:%S.0 %z') +command! InsertTime :normal a=strftime('%F %H:%M:%S %z') ""colorscheme desert "" Status line full path for filename @@ -244,6 +255,8 @@ let g:fzf_preview_git_status_preview_command = \ "[[ $(git diff -- {-1}) != \"\" ]] && git diff --color=always -- {-1} | delta || " . \ g:fzf_preview_command +let g:fzf_preview_directory_files_command = "rg --files --no-ignore-vcs -g\'!.git\'" + Plug 'https://github.com/shumphrey/fugitive-gitlab.vim' Plug 'https://tpope.io/vim/surround.git' Plug 'https://github.com/saltstack/salt-vim' @@ -435,12 +448,16 @@ Plug 'fannheyward/telescope-coc.nvim' Plug 'https://github.com/ludovicchabant/vim-gutentags.git' +Plug 'https://github.com/dbeniamine/cheat.sh-vim' + " API testing "Plug 'baverman/vial' "Plug 'baverman/vial-http' Plug 'emaniacs/vim-rest-console' +Plug 'mbbill/undotree' + let g:vrc_output_buffer_name = '__VRC_OUTPUT.json' let g:python3_host_prog = "/home/legrems/miniconda3/bin/python" @@ -500,16 +517,17 @@ nnoremap :vertical topleft Git vertical resize 50 "nnoremap :Files " Ignore ignored files => all files "nnoremap :CocCommand fzf-preview.DirectoryFiles --no-ignore-vcs -nnoremap :CocCommand fzf-preview.ProjectFiles +nnoremap :CocCommand fzf-preview.GitFiles " Search git file name "nnoremap :GFiles -"nnoremap :CocCommand fzf-preview.DirectoryFiles -nnoremap :CocCommand fzf-preview.GitFiles +nnoremap :CocCommand fzf-preview.DirectoryFiles +"nnoremap :CocCommand fzf-preview.GitFiles " Search buffers "nnoremap :Buffers nnoremap :CocCommand fzf-preview.Buffers " Open Flake8 error -nnoremap :Errors +"nnoremap :Errors +nnoremap :CocCommand fzf-preview.MruFiles " Force write as unix type (/n instead of /r/n) nnoremap :w! ++ff=unix " Force quit @@ -518,6 +536,22 @@ nnoremap :q! " nnoremap :Gdiffsplit nnoremap :tab Git diff % nnoremap :tab Git diff + +nnoremap :UndotreeToggle + +if has("persistent_undo") + let target_path = expand('~/.undodir') + + " create the directory and any parent directories + " if the location does not exist. + if !isdirectory(target_path) + call mkdir(target_path, "p", 0700) + endif + + let &undodir=target_path + set undofile +endif + " Using git-delta " Buffer @@ -541,6 +575,10 @@ vnoremap zf nnoremap dl d$ nnoremap :bprevious nnoremap :bnext +"nnoremap :bprevious +"nnoremap :bnext +nnoremap :bnext +nnoremap :bprevious " Goto file under location nnoremap gf :vertical wincmd f diff --git a/zsh/alias.sh b/zsh/alias.sh index 117a50b..82387d9 100644 --- a/zsh/alias.sh +++ b/zsh/alias.sh @@ -8,6 +8,7 @@ alias pm='python manage.py' alias pmt='clear && pm test' alias sp='python manage.py shell_plus' alias mkmg='python manage.py makemigrations' +alias pms='pm showmigrations' alias mg='python manage.py migrate' alias gp='git push' alias ga!='git commit --amend --no-edit --date now' @@ -16,14 +17,14 @@ alias n='cd . && nvim -S' alias v='nvim' alias vi='nvim' alias vim='nvim' -alias fm='vifm' +alias fm='vifm .' rs() {python manage.py runserver 127.0.0."$1":"$2"} cheat() { curl cheat.sh/"$1" } cda() { conda activate "$@" } cdd() { conda deactivate "$@" } -cdc() { conda create --name "$@" python=3.7 pip ipython memory_profiler psycopg2 black isort } +cdc() { conda create --name "$@" python=3.9 pip ipython memory_profiler psycopg2 black isort } cdi() { conda info --envs "$@" } ca() { pygmentize -g "$@" } grepf() { grep -rnw ./ -e "$@"} From 111ea60970ae2dc5bca3b3c9d5cccaf671d4fce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gremaud?= Date: Mon, 5 Jun 2023 01:25:26 +0200 Subject: [PATCH 3/4] Update 05.06.23 --- Xresources | 6 +++++- gitconfig | 1 + tmux-cht-command | 37 +++++++++++++++++++++++++++++++++++++ tmux-cht-languages | 13 +++++++++++++ vimrc | 2 +- 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 tmux-cht-command create mode 100644 tmux-cht-languages diff --git a/Xresources b/Xresources index 1b75bbf..3e714cc 100644 --- a/Xresources +++ b/Xresources @@ -53,7 +53,11 @@ URxvt.iso14755: false URxvt.iso14755_52: false !URxvt*font: xft:DejaVuSansMono:size=12:style=dzForPowerline -URxvt*font: xft:Courier New:size=12:style=dzForPowerline +! URxvt*font: xft:Courier New:size=12:style=dzForPowerline +URxvt*font: xft:JetBrainsMono Nerd Font:size=12 +URxvt*boldFont: xft:JetBrainsMono Nerd Font:size=12 +URxvt*italicFont: xft:JetBrainsMono Nerd Font:size=12 +URxvt*boldItalicFont: xft:JetBrainsMono Nerd Font:size=12 URxvt.letterSpace: -1 !URxvt.keysym.Alt-Up: resize-font:bigger !URxvt.keysym.Alt-Down: resize-font:smaller diff --git a/gitconfig b/gitconfig index 29dfd4b..e8c5b1a 100644 --- a/gitconfig +++ b/gitconfig @@ -36,6 +36,7 @@ plus-style = "syntax #012800" minus-style = "syntax #340001" syntax-theme = Monokai Extended + ;syntax-theme = gruvbox-dark navigate = true side-by-side = true [interactive] diff --git a/tmux-cht-command b/tmux-cht-command new file mode 100644 index 0000000..04551d3 --- /dev/null +++ b/tmux-cht-command @@ -0,0 +1,37 @@ +find +man +tldr +sed +awk +tr +cp +ls +grep +xargs +rg +ps +mv +kill +lsof +less +head +tail +tar +cp +rm +rename +jq +cat +ssh +cargo +git +git-worktree +git-status +git-commit +git-rebase +docker +docker-compose +stow +chmod +chown +make diff --git a/tmux-cht-languages b/tmux-cht-languages new file mode 100644 index 0000000..9bb44c5 --- /dev/null +++ b/tmux-cht-languages @@ -0,0 +1,13 @@ +python +django-admin +golang +vim +javascript +tmux +zsh +cpp +c +lua +bash +css +html diff --git a/vimrc b/vimrc index 7e2a401..43e57a1 100644 --- a/vimrc +++ b/vimrc @@ -523,7 +523,7 @@ nnoremap :CocCommand fzf-preview.GitFiles nnoremap :CocCommand fzf-preview.DirectoryFiles "nnoremap :CocCommand fzf-preview.GitFiles " Search buffers -"nnoremap :Buffers +" nnoremap :Buffers nnoremap :CocCommand fzf-preview.Buffers " Open Flake8 error "nnoremap :Errors From ad11b0727a945f8ce5610b563c5bc2b070904856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gremaud?= Date: Mon, 5 Jun 2023 01:44:54 +0200 Subject: [PATCH 4/4] Add neovim submodules --- neovim | 1 + 1 file changed, 1 insertion(+) create mode 160000 neovim diff --git a/neovim b/neovim new file mode 160000 index 0000000..722044c --- /dev/null +++ b/neovim @@ -0,0 +1 @@ +Subproject commit 722044c88a110bc80554b6a73da0f9b4f47e7a90