From b18e9a774276dfe14d7d30e000d73dd3b6bc7533 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Sat, 28 Apr 2018 10:03:47 +0200 Subject: Removed '.' in front of dotfiles, started on install script, changed hyper, added bash, added tmux --- Hyperterm/.hyper.js | 111 --------------- Hyperterm/hyper.js | 111 +++++++++++++++ bash/bashrc | 1 + bin/install.sh | 4 + tmux.conf | 14 ++ vim/_vimrc | 382 ---------------------------------------------------- vim/vimrc | 382 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 512 insertions(+), 493 deletions(-) delete mode 100644 Hyperterm/.hyper.js create mode 100644 Hyperterm/hyper.js create mode 100644 bash/bashrc create mode 100755 bin/install.sh create mode 100644 tmux.conf delete mode 100644 vim/_vimrc create mode 100644 vim/vimrc diff --git a/Hyperterm/.hyper.js b/Hyperterm/.hyper.js deleted file mode 100644 index 169b16d..0000000 --- a/Hyperterm/.hyper.js +++ /dev/null @@ -1,111 +0,0 @@ - -module.exports = { - config: { - // default font size in pixels for all tabs - fontSize: 12, - - // font family with optional fallbacks - fontFamily: '"Roboto Mono", "Fira Code", Menlo, "DejaVu Sans Mono", "Lucida Console", monospace', - - // terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk) - cursorColor: '#2C85F7', - - // `BEAM` for |, `UNDERLINE` for _, `BLOCK` for █ - cursorShape: 'BLOCK', - - // color of the text - foregroundColor: '#00ff00', - - // terminal background color - backgroundColor: '#293340', - - // border color (window, tabs) - borderColor: '#323E4D', - - // custom css to embed in the main window - css: ` - ::selection { - background: #9198A2 !important; - } - x-screen x-row { - font-variant-ligatures: initial; - } - span { - font-weight: normal !important; - } - `, - - // custom css to embed in the terminal window - termCSS: '', - - // set to `true` if you're using a Linux set up - // that doesn't shows native menus - // default: `false` on Linux, `true` on Windows (ignored on macOS) - showHamburgerMenu: '', - - // set to `false` if you want to hide the minimize, maximize and close buttons - // additionally, set to `'left'` if you want them on the left, like in Ubuntu - // default: `true` on windows and Linux (ignored on macOS) - showWindowControls: true, - - // custom padding (css format, i.e.: `top right bottom left`) - padding: '12px 14px', - - // the full list. if you're going to provide the full color palette, - // including the 6 x 6 color cubes and the grayscale map, just provide - // an array here instead of a color map object - colors: { - black : '#293340', - red : '#E17E85', - green : '#61BA86', - yellow : '#FFEC8E', - blue : '#4CB2FF', - magenta : '#BE86E3', - cyan : '#2DCED0', - white : '#CDD2E9', - lightBlack : '#546386', - lightRed : '#E17E85', - lightGreen : '#61BA86', - lightYellow : '#FFB68E', - lightBlue : '#4CB2FF', - lightMagenta : '#BE86E3', - lightCyan : '#2DCED0', - lightWhite : '#CDD2E9' - }, - - // the shell to run when spawning a new session (i.e. /usr/local/bin/fish) - // if left empty, your system's login shell will be used by default - shell: '', - - // for setting shell arguments (i.e. for using interactive shellArgs: ['-i']) - // by default ['--login'] will be used - shellArgs: ['--login'], - - // for environment variables - env: {}, - - // set to false for no bell - bell: 'SOUND', - - // if true, selected text will automatically be copied to the clipboard - copyOnSelect: false - - // URL to custom bell - // bellSoundURL: 'http://example.com/bell.mp3', - - // for advanced config flags please refer to https://hyper.is/#cfg - }, - - // a list of plugins to fetch and install from npm - // format: [@org/]project[#version] - // examples: - // `hyperpower` - // `@company/project` - // `project#1.0.1` - plugins: [ 'hyperline#0.6.1', 'hyper-dark-scrollbar', 'hypercwd', 'hyperlinks', 'gitrocket', 'space-pull', 'hyper-blink' ], - - // in development, you can create a directory under - // `~/.hyper_plugins/local/` and include it here - // to load it and avoid it being `npm install`ed - localPlugins: [] -}; diff --git a/Hyperterm/hyper.js b/Hyperterm/hyper.js new file mode 100644 index 0000000..169b16d --- /dev/null +++ b/Hyperterm/hyper.js @@ -0,0 +1,111 @@ + +module.exports = { + config: { + // default font size in pixels for all tabs + fontSize: 12, + + // font family with optional fallbacks + fontFamily: '"Roboto Mono", "Fira Code", Menlo, "DejaVu Sans Mono", "Lucida Console", monospace', + + // terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk) + cursorColor: '#2C85F7', + + // `BEAM` for |, `UNDERLINE` for _, `BLOCK` for █ + cursorShape: 'BLOCK', + + // color of the text + foregroundColor: '#00ff00', + + // terminal background color + backgroundColor: '#293340', + + // border color (window, tabs) + borderColor: '#323E4D', + + // custom css to embed in the main window + css: ` + ::selection { + background: #9198A2 !important; + } + x-screen x-row { + font-variant-ligatures: initial; + } + span { + font-weight: normal !important; + } + `, + + // custom css to embed in the terminal window + termCSS: '', + + // set to `true` if you're using a Linux set up + // that doesn't shows native menus + // default: `false` on Linux, `true` on Windows (ignored on macOS) + showHamburgerMenu: '', + + // set to `false` if you want to hide the minimize, maximize and close buttons + // additionally, set to `'left'` if you want them on the left, like in Ubuntu + // default: `true` on windows and Linux (ignored on macOS) + showWindowControls: true, + + // custom padding (css format, i.e.: `top right bottom left`) + padding: '12px 14px', + + // the full list. if you're going to provide the full color palette, + // including the 6 x 6 color cubes and the grayscale map, just provide + // an array here instead of a color map object + colors: { + black : '#293340', + red : '#E17E85', + green : '#61BA86', + yellow : '#FFEC8E', + blue : '#4CB2FF', + magenta : '#BE86E3', + cyan : '#2DCED0', + white : '#CDD2E9', + lightBlack : '#546386', + lightRed : '#E17E85', + lightGreen : '#61BA86', + lightYellow : '#FFB68E', + lightBlue : '#4CB2FF', + lightMagenta : '#BE86E3', + lightCyan : '#2DCED0', + lightWhite : '#CDD2E9' + }, + + // the shell to run when spawning a new session (i.e. /usr/local/bin/fish) + // if left empty, your system's login shell will be used by default + shell: '', + + // for setting shell arguments (i.e. for using interactive shellArgs: ['-i']) + // by default ['--login'] will be used + shellArgs: ['--login'], + + // for environment variables + env: {}, + + // set to false for no bell + bell: 'SOUND', + + // if true, selected text will automatically be copied to the clipboard + copyOnSelect: false + + // URL to custom bell + // bellSoundURL: 'http://example.com/bell.mp3', + + // for advanced config flags please refer to https://hyper.is/#cfg + }, + + // a list of plugins to fetch and install from npm + // format: [@org/]project[#version] + // examples: + // `hyperpower` + // `@company/project` + // `project#1.0.1` + plugins: [ 'hyperline#0.6.1', 'hyper-dark-scrollbar', 'hypercwd', 'hyperlinks', 'gitrocket', 'space-pull', 'hyper-blink' ], + + // in development, you can create a directory under + // `~/.hyper_plugins/local/` and include it here + // to load it and avoid it being `npm install`ed + localPlugins: [] +}; diff --git a/bash/bashrc b/bash/bashrc new file mode 100644 index 0000000..36357ee --- /dev/null +++ b/bash/bashrc @@ -0,0 +1 @@ +alias lamp='curl -i -H Accept: application/json -H Content-Type: application/json -X GET http://192.168.10.191/j?lamp=toggle' diff --git a/bin/install.sh b/bin/install.sh new file mode 100755 index 0000000..14fd058 --- /dev/null +++ b/bin/install.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cp tmux/tmux.conf ~/.tmux.conf +cp bash/bashrc ~/.bashrc diff --git a/tmux.conf b/tmux.conf new file mode 100644 index 0000000..3b9f619 --- /dev/null +++ b/tmux.conf @@ -0,0 +1,14 @@ +unbind C-b +set -g prefix C-a + +bind -n M-Left select-pane -L +bind -n M-Right select-pane -R +bind -n M-Up select-pane -U +bind -n M-Down select-pane -D + +setw -g monitor-activity on +set -g visual-activity on + +set-window-option -g window-status-current-bg yellow + + diff --git a/vim/_vimrc b/vim/_vimrc deleted file mode 100644 index 84216c1..0000000 --- a/vim/_vimrc +++ /dev/null @@ -1,382 +0,0 @@ - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Maintainer: -" jakobs1n -" -" Version: -" 1.0 - 19/03/18 11:00:34 -" -" Sections: -" -> General -" -> VIM user interface -" -> Colors and Fonts -" -> Files and backups -" -> Text, tab and indent related -" -> Visual mode related -" -> Moving around, tabs and buffers -" -> Status line -" -> Editing mappings -" -> vimgrep searching and cope displaying -" -> Spell checking -" -> Misc -" -> Helper functions -" -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => General -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Sets how many lines of history VIM has to remember -set history=500 -set nu -" Enable filetype plugins -filetype plugin on -filetype indent on - -" Set to auto read when a file is changed from the outside -set autoread - -" With a map leader it's possible to do extra key combinations -" like w saves the current file -let mapleader = "," -let g:mapleader = "," - -" Fast saving -nmap w :w! - -" :W sudo saves the file -" (useful for handling the permission-denied error) -command W w !sudo tee % > /dev/null - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => VIM user interface -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Set 7 lines to the cursor - when moving vertically using j/k -set so=7 - -" Avoid garbled characters in Chinese language windows OS -let $LANG='en' -set langmenu=en -source $VIMRUNTIME/delmenu.vim -source $VIMRUNTIME/menu.vim - -" Turn on the WiLd menu -set wildmenu - -" Ignore compiled files -set wildignore=*.o,*~,*.pyc -if has("win16") || has("win32") - set wildignore+=.git\*,.hg\*,.svn\* -else - set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store -endif - -"Always show current position -set ruler - -" Height of the command bar -set cmdheight=2 - -" A buffer becomes hidden when it is abandoned -set hid - -" Configure backspace so it acts as it should act -set backspace=eol,start,indent -set whichwrap+=<,>,h,l - -" Ignore case when searching -set ignorecase - -" When searching try to be smart about cases -set smartcase - -" Highlight search results -set hlsearch - -" Makes search act like search in modern browsers -set incsearch - -" Don't redraw while executing macros (good performance config) -set lazyredraw - -" For regular expressions turn magic on -set magic - -" Show matching brackets when text indicator is over them -set showmatch -" How many tenths of a second to blink when matching brackets -set mat=2 - -" No annoying sound on errors -set noerrorbells -set novisualbell -set t_vb= -set tm=500 - -" Properly disable sound on errors on MacVim -if has("gui_macvim") - autocmd GUIEnter * set vb t_vb= -endif - - -" Add a bit extra margin to the left -set foldcolumn=1 - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Colors and Fonts -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Enable syntax highlighting -syntax enable - -" Enable 256 colors palette in Gnome Terminal -if $COLORTERM == 'gnome-terminal' - set t_Co=256 -endif - -try - colorscheme evening -catch -endtry - -set background=dark - -" Set extra options when running in GUI mode -if has("gui_running") - set guioptions-=T - set guioptions-=e - set t_Co=256 - set guitablabel=%M\ %t -endif - -" Set utf8 as standard encoding and en_US as the standard language -set encoding=utf8 - -" Use Unix as the standard file type -set ffs=unix,dos,mac - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Files, backups and undo -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Turn backup off, since most stuff is in SVN, git et.c anyway... -set nobackup -set nowb -set noswapfile - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Text, tab and indent related -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Use spaces instead of tabs -set expandtab - -" Be smart when using tabs ;) -set smarttab - -" 1 tab == 4 spaces -set shiftwidth=4 -set tabstop=4 - -" Linebreak on 500 characters -set lbr -set tw=500 - -set ai "Auto indent -set si "Smart indent -set wrap "Wrap lines - - -"""""""""""""""""""""""""""""" -" => Visual mode related -"""""""""""""""""""""""""""""" -" Visual mode pressing * or # searches for the current selection -" Super useful! From an idea by Michael Naumann -vnoremap * :call VisualSelection('', '')/=@/ -vnoremap # :call VisualSelection('', '')?=@/ - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Moving around, tabs, windows and buffers -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Map to / (search) and Ctrl- to ? (backwards search) -map / -map ? - -" Disable highlight when is pressed -map :noh - -" Smart way to move between windows -map j -map k -map h -map l - -" Close the current buffer -map bd :Bclose:tabclosegT - -" Close all the buffers -map ba :bufdo bd - -map l :bnext -map h :bprevious - -" Useful mappings for managing tabs -map tn :tabnew -map to :tabonly -map tc :tabclose -map tm :tabmove -map t :tabnext - -" Let 'tl' toggle between this and the last accessed tab -let g:lasttab = 1 -nmap tl :exe "tabn ".g:lasttab -au TabLeave * let g:lasttab = tabpagenr() - - -" Opens a new tab with the current buffer's path -" Super useful when editing files in the same directory -map te :tabedit =expand("%:p:h")/ - -" Switch CWD to the directory of the open buffer -map cd :cd %:p:h:pwd - -" Specify the behavior when switching between buffers -try - set switchbuf=useopen,usetab,newtab - set stal=2 -catch -endtry - -" Return to last edit position when opening files (You want this!) -au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif - - -"""""""""""""""""""""""""""""" -" => Status line -"""""""""""""""""""""""""""""" -" Always show the status line -set laststatus=2 - -" Format the status line -set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Editing mappings -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Remap VIM 0 to first non-blank character -map 0 ^ - -" Move a line of text using ALT+[jk] or Command+[jk] on mac -nmap mz:m+`z -nmap mz:m-2`z -vmap :m'>+`mzgv`yo`z -vmap :m'<-2`>my` - nmap - vmap - vmap -endif - -" Delete trailing white space on save, useful for some filetypes ;) -fun! CleanExtraSpaces() - let save_cursor = getpos(".") - let old_query = getreg('/') - silent! %s/\s\+$//e - call setpos('.', save_cursor) - call setreg('/', old_query) -endfun - -if has("autocmd") - autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces() -endif - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Spell checking -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Pressing ,ss will toggle and untoggle spell checking -map ss :setlocal spell! - -" Shortcuts using -map sn ]s -map sp [s -map sa zg -map s? z= - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Misc -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Remove the Windows ^M - when the encodings gets messed up -noremap m mmHmt:%s///ge'tzt'm - -" Quickly open a buffer for scribble -map q :e ~/buffer - -" Quickly open a markdown buffer for scribble -map x :e ~/buffer.md - -" Toggle paste mode on and off -map pp :setlocal paste! - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Helper functions -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Returns true if paste mode is enabled -function! HasPaste() - if &paste - return 'PASTE MODE ' - endif - return '' -endfunction - -" Don't close window, when deleting a buffer -command! Bclose call BufcloseCloseIt() -function! BufcloseCloseIt() - let l:currentBufNum = bufnr("%") - let l:alternateBufNum = bufnr("#") - - if buflisted(l:alternateBufNum) - buffer # - else - bnext - endif - - if bufnr("%") == l:currentBufNum - new - endif - - if buflisted(l:currentBufNum) - execute("bdelete! ".l:currentBufNum) - endif -endfunction - -function! CmdLine(str) - exe "menu Foo.Bar :" . a:str - emenu Foo.Bar - unmenu Foo -endfunction - -function! VisualSelection(direction, extra_filter) range - let l:saved_reg = @" - execute "normal! vgvy" - - let l:pattern = escape(@", "\\/.*'$^~[]") - let l:pattern = substitute(l:pattern, "\n$", "", "") - - if a:direction == 'gv' - call CmdLine("Ack '" . l:pattern . "' " ) - elseif a:direction == 'replace' - call CmdLine("%s" . '/'. l:pattern . '/') - endif - - let @/ = l:pattern - let @" = l:saved_reg -endfunction diff --git a/vim/vimrc b/vim/vimrc new file mode 100644 index 0000000..84216c1 --- /dev/null +++ b/vim/vimrc @@ -0,0 +1,382 @@ + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Maintainer: +" jakobs1n +" +" Version: +" 1.0 - 19/03/18 11:00:34 +" +" Sections: +" -> General +" -> VIM user interface +" -> Colors and Fonts +" -> Files and backups +" -> Text, tab and indent related +" -> Visual mode related +" -> Moving around, tabs and buffers +" -> Status line +" -> Editing mappings +" -> vimgrep searching and cope displaying +" -> Spell checking +" -> Misc +" -> Helper functions +" +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => General +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Sets how many lines of history VIM has to remember +set history=500 +set nu +" Enable filetype plugins +filetype plugin on +filetype indent on + +" Set to auto read when a file is changed from the outside +set autoread + +" With a map leader it's possible to do extra key combinations +" like w saves the current file +let mapleader = "," +let g:mapleader = "," + +" Fast saving +nmap w :w! + +" :W sudo saves the file +" (useful for handling the permission-denied error) +command W w !sudo tee % > /dev/null + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => VIM user interface +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Set 7 lines to the cursor - when moving vertically using j/k +set so=7 + +" Avoid garbled characters in Chinese language windows OS +let $LANG='en' +set langmenu=en +source $VIMRUNTIME/delmenu.vim +source $VIMRUNTIME/menu.vim + +" Turn on the WiLd menu +set wildmenu + +" Ignore compiled files +set wildignore=*.o,*~,*.pyc +if has("win16") || has("win32") + set wildignore+=.git\*,.hg\*,.svn\* +else + set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store +endif + +"Always show current position +set ruler + +" Height of the command bar +set cmdheight=2 + +" A buffer becomes hidden when it is abandoned +set hid + +" Configure backspace so it acts as it should act +set backspace=eol,start,indent +set whichwrap+=<,>,h,l + +" Ignore case when searching +set ignorecase + +" When searching try to be smart about cases +set smartcase + +" Highlight search results +set hlsearch + +" Makes search act like search in modern browsers +set incsearch + +" Don't redraw while executing macros (good performance config) +set lazyredraw + +" For regular expressions turn magic on +set magic + +" Show matching brackets when text indicator is over them +set showmatch +" How many tenths of a second to blink when matching brackets +set mat=2 + +" No annoying sound on errors +set noerrorbells +set novisualbell +set t_vb= +set tm=500 + +" Properly disable sound on errors on MacVim +if has("gui_macvim") + autocmd GUIEnter * set vb t_vb= +endif + + +" Add a bit extra margin to the left +set foldcolumn=1 + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Colors and Fonts +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Enable syntax highlighting +syntax enable + +" Enable 256 colors palette in Gnome Terminal +if $COLORTERM == 'gnome-terminal' + set t_Co=256 +endif + +try + colorscheme evening +catch +endtry + +set background=dark + +" Set extra options when running in GUI mode +if has("gui_running") + set guioptions-=T + set guioptions-=e + set t_Co=256 + set guitablabel=%M\ %t +endif + +" Set utf8 as standard encoding and en_US as the standard language +set encoding=utf8 + +" Use Unix as the standard file type +set ffs=unix,dos,mac + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Files, backups and undo +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Turn backup off, since most stuff is in SVN, git et.c anyway... +set nobackup +set nowb +set noswapfile + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Text, tab and indent related +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Use spaces instead of tabs +set expandtab + +" Be smart when using tabs ;) +set smarttab + +" 1 tab == 4 spaces +set shiftwidth=4 +set tabstop=4 + +" Linebreak on 500 characters +set lbr +set tw=500 + +set ai "Auto indent +set si "Smart indent +set wrap "Wrap lines + + +"""""""""""""""""""""""""""""" +" => Visual mode related +"""""""""""""""""""""""""""""" +" Visual mode pressing * or # searches for the current selection +" Super useful! From an idea by Michael Naumann +vnoremap * :call VisualSelection('', '')/=@/ +vnoremap # :call VisualSelection('', '')?=@/ + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Moving around, tabs, windows and buffers +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Map to / (search) and Ctrl- to ? (backwards search) +map / +map ? + +" Disable highlight when is pressed +map :noh + +" Smart way to move between windows +map j +map k +map h +map l + +" Close the current buffer +map bd :Bclose:tabclosegT + +" Close all the buffers +map ba :bufdo bd + +map l :bnext +map h :bprevious + +" Useful mappings for managing tabs +map tn :tabnew +map to :tabonly +map tc :tabclose +map tm :tabmove +map t :tabnext + +" Let 'tl' toggle between this and the last accessed tab +let g:lasttab = 1 +nmap tl :exe "tabn ".g:lasttab +au TabLeave * let g:lasttab = tabpagenr() + + +" Opens a new tab with the current buffer's path +" Super useful when editing files in the same directory +map te :tabedit =expand("%:p:h")/ + +" Switch CWD to the directory of the open buffer +map cd :cd %:p:h:pwd + +" Specify the behavior when switching between buffers +try + set switchbuf=useopen,usetab,newtab + set stal=2 +catch +endtry + +" Return to last edit position when opening files (You want this!) +au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif + + +"""""""""""""""""""""""""""""" +" => Status line +"""""""""""""""""""""""""""""" +" Always show the status line +set laststatus=2 + +" Format the status line +set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Editing mappings +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Remap VIM 0 to first non-blank character +map 0 ^ + +" Move a line of text using ALT+[jk] or Command+[jk] on mac +nmap mz:m+`z +nmap mz:m-2`z +vmap :m'>+`mzgv`yo`z +vmap :m'<-2`>my` + nmap + vmap + vmap +endif + +" Delete trailing white space on save, useful for some filetypes ;) +fun! CleanExtraSpaces() + let save_cursor = getpos(".") + let old_query = getreg('/') + silent! %s/\s\+$//e + call setpos('.', save_cursor) + call setreg('/', old_query) +endfun + +if has("autocmd") + autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces() +endif + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Spell checking +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Pressing ,ss will toggle and untoggle spell checking +map ss :setlocal spell! + +" Shortcuts using +map sn ]s +map sp [s +map sa zg +map s? z= + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Misc +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Remove the Windows ^M - when the encodings gets messed up +noremap m mmHmt:%s///ge'tzt'm + +" Quickly open a buffer for scribble +map q :e ~/buffer + +" Quickly open a markdown buffer for scribble +map x :e ~/buffer.md + +" Toggle paste mode on and off +map pp :setlocal paste! + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Helper functions +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Returns true if paste mode is enabled +function! HasPaste() + if &paste + return 'PASTE MODE ' + endif + return '' +endfunction + +" Don't close window, when deleting a buffer +command! Bclose call BufcloseCloseIt() +function! BufcloseCloseIt() + let l:currentBufNum = bufnr("%") + let l:alternateBufNum = bufnr("#") + + if buflisted(l:alternateBufNum) + buffer # + else + bnext + endif + + if bufnr("%") == l:currentBufNum + new + endif + + if buflisted(l:currentBufNum) + execute("bdelete! ".l:currentBufNum) + endif +endfunction + +function! CmdLine(str) + exe "menu Foo.Bar :" . a:str + emenu Foo.Bar + unmenu Foo +endfunction + +function! VisualSelection(direction, extra_filter) range + let l:saved_reg = @" + execute "normal! vgvy" + + let l:pattern = escape(@", "\\/.*'$^~[]") + let l:pattern = substitute(l:pattern, "\n$", "", "") + + if a:direction == 'gv' + call CmdLine("Ack '" . l:pattern . "' " ) + elseif a:direction == 'replace' + call CmdLine("%s" . '/'. l:pattern . '/') + endif + + let @/ = l:pattern + let @" = l:saved_reg +endfunction -- cgit v1.2.3