Compare commits
78 Commits
83a63be678
...
new-setup-
| Author | SHA1 | Date | |
|---|---|---|---|
| d19e60cfc3 | |||
| 0ee1e7666e | |||
| c7845e62d9 | |||
| 2a57ce8837 | |||
| a529cd6560 | |||
| 589abb9e46 | |||
| 6df4a1e506 | |||
| 10c6e8e06c | |||
| f70bc8b9cd | |||
| dad6be889f | |||
| e979d1094c | |||
| ce1599466e | |||
| e5e8f309e5 | |||
| 8ff9c338b5 | |||
| 173bda9eb0 | |||
| 06bbc0c995 | |||
| f19e84e1a5 | |||
| 1a46964bd7 | |||
| 0e91857946 | |||
| bb31351404 | |||
| 7b031d3127 | |||
| c05131d38f | |||
| 418d1ae956 | |||
| e614936478 | |||
| 5bed58e55c | |||
| 6800f7ccc4 | |||
| 40eb9aa808 | |||
| 53082c6034 | |||
| f084b19637 | |||
| 4323bd9721 | |||
| 28c88ca5f1 | |||
| 4464e4f681 | |||
| 08a26b6716 | |||
| 84b221bdb9 | |||
| 2e07b0c85f | |||
| d664ba882c | |||
| 2f9dc3aba7 | |||
| f0248008a6 | |||
| 7e586d284d | |||
| 816a0be564 | |||
| cef7886859 | |||
| 9e07b24cf7 | |||
| 12969578aa | |||
| 89d5709677 | |||
| 2343c46b89 | |||
| 9371817937 | |||
| 8eccc9659a | |||
| 45d3fa244a | |||
| 2640761dc5 | |||
| 0227534656 | |||
| 78fd8f6d45 | |||
| 736bab22ec | |||
| 0a7bb3c2a1 | |||
| c0dd5208a0 | |||
| 7c828c01f1 | |||
| c1e333e7db | |||
| 4238273951 | |||
| 7f121ab292 | |||
| f30f6eaa69 | |||
| 221985eca2 | |||
| 06f155f3f7 | |||
| 648e9bcce5 | |||
| b9709088a7 | |||
| dfa5ecaf47 | |||
| 75019980ea | |||
| 4be87e93b1 | |||
| 7a7c9c87be | |||
| 6965090c6f | |||
| ee3aa1a046 | |||
| ae13200d2e | |||
| c0e6c0414b | |||
| 9ed266f056 | |||
| b78306c95b | |||
| d828033f36 | |||
| dc15320039 | |||
| 8bc573bfad | |||
| 6b23065119 | |||
| 761ef7815d |
File diff suppressed because it is too large
Load Diff
@@ -30,7 +30,7 @@ parse_git_branch() {
|
||||
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
|
||||
fi
|
||||
}
|
||||
export PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u\[\033[0;36m\] @ \w\[\033[33m\]\n$(parse_git_branch)\[\033[0;32m\]\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\]\[\033[0m\] '
|
||||
export PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u\[\033[0;36m\] -> \w\[\033[33m\]\n$(parse_git_branch)\[\033[0;32m\]\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\]\[\033[0m\] '
|
||||
|
||||
# Git autocompletion.
|
||||
if [ -f ~/.git-completion.bash ]; then
|
||||
@@ -13,16 +13,20 @@ esac
|
||||
export PLATFORM=$platform
|
||||
export PLATFORM_OS=$platform_os
|
||||
|
||||
test -f "$HOME/.env.platform" && . "$HOME/.env.platform"
|
||||
os_lower="${platform_os,,}"
|
||||
test -f "$HOME/dotfiles/${os_lower}/env.platform" && . "$HOME/dotfiles/${os_lower}/env.platform"
|
||||
|
||||
test -f "$HOME/.env.common-pre" && . "$HOME/.env.common-pre"
|
||||
test -f "$HOME/.env.private" && . "$HOME/.env.private"
|
||||
test -f "$HOME/.env.common-post" && . "$HOME/.env.common-post"
|
||||
|
||||
test -f "$HOME/.aliases" && . "$HOME/.aliases"
|
||||
test -f "$HOME/.aliases.common" && . "$HOME/.aliases.common"
|
||||
test -f "$HOME/.aliases.private" && . "$HOME/.aliases.private"
|
||||
|
||||
if [[ $_MC_SET_ENV_PATH -ne 1 ]]; then
|
||||
test -d "$HOME/bin" && export PATH=$HOME/bin/:$PATH
|
||||
#TODO: remove this
|
||||
test -d "$HOME/.dotfiles/bin" && export PATH=$HOME/.dotfiles/bin/:$PATH
|
||||
fi
|
||||
|
||||
5
.gitattributes
vendored
Normal file
5
.gitattributes
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
# All text files will have LF line endings, except batch files.
|
||||
* text=auto
|
||||
|
||||
# Preserve crlf in batch files when checking in.
|
||||
*.bat text eol=crlf
|
||||
@@ -1,5 +1,4 @@
|
||||
[include]
|
||||
path = ~/.gitconfig.platform
|
||||
path = ~/.gitconfig.private
|
||||
[init]
|
||||
defaultBranch = master
|
||||
@@ -7,10 +6,25 @@
|
||||
summary = true
|
||||
tool = vimdiff
|
||||
[core]
|
||||
excludesfile = ~/.gitignore
|
||||
excludesfile = ~/.gitignore.global
|
||||
hookspath = ~/.git_hooks
|
||||
preloadindex = true
|
||||
fscache = true
|
||||
editor = vim
|
||||
# I used to have this set to true, which would result in checked out files
|
||||
# being converted to CRLF line endings and commits converting to LF. I'm
|
||||
# tired of this conversion shit though so I'm turning it off and will be
|
||||
# enforcing LF line endings via a combination of editorconfig and
|
||||
# gitattribute files on a per-project basis. This should make sure that
|
||||
# anyone contributing to my projects will be committing LF line endings.
|
||||
# The only exception is that the gitattributes files will commit batch
|
||||
# files with CRLF to avoid Windows glitches.
|
||||
#
|
||||
# I used these posts for reference:
|
||||
# https://markentier.tech/posts/2021/10/autocrlf-true-considered-harmful/
|
||||
# https://troyready.com/blog/git-windows-dont-convert-line-endings.html
|
||||
#
|
||||
autocrlf = false
|
||||
[push]
|
||||
default = upstream
|
||||
[pull]
|
||||
9
.gitignore
vendored
9
.gitignore
vendored
@@ -1,8 +1 @@
|
||||
vim/.netrwhist
|
||||
vim/bundle/*
|
||||
vim/plugged/*
|
||||
vim/undo
|
||||
vim/undo/*
|
||||
config/openbox/lxde-rc.xml
|
||||
*.pyc
|
||||
!bin
|
||||
*
|
||||
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
||||
[submodule "vim/bundle/Vundle.vim"]
|
||||
path = vim/bundle/Vundle.vim
|
||||
url = https://github.com/VundleVim/Vundle.vim.git
|
||||
@@ -25,7 +25,7 @@
|
||||
" Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
|
||||
" Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
|
||||
"
|
||||
" " Using a non-master branch
|
||||
" " Using a non-default branch
|
||||
" Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
|
||||
"
|
||||
" " Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
|
||||
@@ -106,7 +106,7 @@ if s:is_win && &shellslash
|
||||
else
|
||||
let s:me = resolve(expand('<sfile>:p'))
|
||||
endif
|
||||
let s:base_spec = { 'branch': 'master', 'frozen': 0 }
|
||||
let s:base_spec = { 'branch': '', 'frozen': 0 }
|
||||
let s:TYPE = {
|
||||
\ 'string': type(''),
|
||||
\ 'list': type([]),
|
||||
@@ -116,6 +116,94 @@ let s:TYPE = {
|
||||
let s:loaded = get(s:, 'loaded', {})
|
||||
let s:triggers = get(s:, 'triggers', {})
|
||||
|
||||
function! s:is_powershell(shell)
|
||||
return a:shell =~# 'powershell\(\.exe\)\?$' || a:shell =~# 'pwsh\(\.exe\)\?$'
|
||||
endfunction
|
||||
|
||||
function! s:isabsolute(dir) abort
|
||||
return a:dir =~# '^/' || (has('win32') && a:dir =~? '^\%(\\\|[A-Z]:\)')
|
||||
endfunction
|
||||
|
||||
function! s:git_dir(dir) abort
|
||||
let gitdir = s:trim(a:dir) . '/.git'
|
||||
if isdirectory(gitdir)
|
||||
return gitdir
|
||||
endif
|
||||
if !filereadable(gitdir)
|
||||
return ''
|
||||
endif
|
||||
let gitdir = matchstr(get(readfile(gitdir), 0, ''), '^gitdir: \zs.*')
|
||||
if len(gitdir) && !s:isabsolute(gitdir)
|
||||
let gitdir = a:dir . '/' . gitdir
|
||||
endif
|
||||
return isdirectory(gitdir) ? gitdir : ''
|
||||
endfunction
|
||||
|
||||
function! s:git_origin_url(dir) abort
|
||||
let gitdir = s:git_dir(a:dir)
|
||||
let config = gitdir . '/config'
|
||||
if empty(gitdir) || !filereadable(config)
|
||||
return ''
|
||||
endif
|
||||
return matchstr(join(readfile(config)), '\[remote "origin"\].\{-}url\s*=\s*\zs\S*\ze')
|
||||
endfunction
|
||||
|
||||
function! s:git_revision(dir) abort
|
||||
let gitdir = s:git_dir(a:dir)
|
||||
let head = gitdir . '/HEAD'
|
||||
if empty(gitdir) || !filereadable(head)
|
||||
return ''
|
||||
endif
|
||||
|
||||
let line = get(readfile(head), 0, '')
|
||||
let ref = matchstr(line, '^ref: \zs.*')
|
||||
if empty(ref)
|
||||
return line
|
||||
endif
|
||||
|
||||
if filereadable(gitdir . '/' . ref)
|
||||
return get(readfile(gitdir . '/' . ref), 0, '')
|
||||
endif
|
||||
|
||||
if filereadable(gitdir . '/packed-refs')
|
||||
for line in readfile(gitdir . '/packed-refs')
|
||||
if line =~# ' ' . ref
|
||||
return matchstr(line, '^[0-9a-f]*')
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! s:git_local_branch(dir) abort
|
||||
let gitdir = s:git_dir(a:dir)
|
||||
let head = gitdir . '/HEAD'
|
||||
if empty(gitdir) || !filereadable(head)
|
||||
return ''
|
||||
endif
|
||||
let branch = matchstr(get(readfile(head), 0, ''), '^ref: refs/heads/\zs.*')
|
||||
return len(branch) ? branch : 'HEAD'
|
||||
endfunction
|
||||
|
||||
function! s:git_origin_branch(spec)
|
||||
if len(a:spec.branch)
|
||||
return a:spec.branch
|
||||
endif
|
||||
|
||||
" The file may not be present if this is a local repository
|
||||
let gitdir = s:git_dir(a:spec.dir)
|
||||
let origin_head = gitdir.'/refs/remotes/origin/HEAD'
|
||||
if len(gitdir) && filereadable(origin_head)
|
||||
return matchstr(get(readfile(origin_head), 0, ''),
|
||||
\ '^ref: refs/remotes/origin/\zs.*')
|
||||
endif
|
||||
|
||||
" The command may not return the name of a branch in detached HEAD state
|
||||
let result = s:lines(s:system('git symbolic-ref --short HEAD', a:spec.dir))
|
||||
return v:shell_error ? '' : result[-1]
|
||||
endfunction
|
||||
|
||||
if s:is_win
|
||||
function! s:plug_call(fn, ...)
|
||||
let shellslash = &shellslash
|
||||
@@ -154,6 +242,8 @@ function! plug#begin(...)
|
||||
let home = s:path(s:plug_fnamemodify(s:plug_expand(a:1), ':p'))
|
||||
elseif exists('g:plug_home')
|
||||
let home = s:path(g:plug_home)
|
||||
elseif has('nvim')
|
||||
let home = stdpath('data') . '/plugged'
|
||||
elseif !empty(&rtp)
|
||||
let home = s:path(split(&rtp, ',')[0]) . '/plugged'
|
||||
else
|
||||
@@ -179,7 +269,7 @@ function! s:define_commands()
|
||||
endif
|
||||
if has('win32')
|
||||
\ && &shellslash
|
||||
\ && (&shell =~# 'cmd\(\.exe\)\?$' || &shell =~# 'powershell\(\.exe\)\?$')
|
||||
\ && (&shell =~# 'cmd\(\.exe\)\?$' || s:is_powershell(&shell))
|
||||
return s:err('vim-plug does not support shell, ' . &shell . ', when shellslash is set.')
|
||||
endif
|
||||
if !has('nvim')
|
||||
@@ -262,7 +352,7 @@ function! plug#end()
|
||||
endif
|
||||
let lod = { 'ft': {}, 'map': {}, 'cmd': {} }
|
||||
|
||||
if exists('g:did_load_filetypes')
|
||||
if get(g:, 'did_load_filetypes', 0)
|
||||
filetype off
|
||||
endif
|
||||
for name in g:plugs_order
|
||||
@@ -317,7 +407,7 @@ function! plug#end()
|
||||
|
||||
for [map, names] in items(lod.map)
|
||||
for [mode, map_prefix, key_prefix] in
|
||||
\ [['i', '<C-O>', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']]
|
||||
\ [['i', '<C-\><C-O>', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']]
|
||||
execute printf(
|
||||
\ '%snoremap <silent> %s %s:<C-U>call <SID>lod_map(%s, %s, %s, "%s")<CR>',
|
||||
\ mode, map, map_prefix, string(map), string(names), mode != 'i', key_prefix)
|
||||
@@ -419,7 +509,7 @@ if s:is_win
|
||||
let batchfile = s:plug_tempname().'.bat'
|
||||
call writefile(s:wrap_cmds(a:cmd), batchfile)
|
||||
let cmd = plug#shellescape(batchfile, {'shell': &shell, 'script': 0})
|
||||
if &shell =~# 'powershell\(\.exe\)\?$'
|
||||
if s:is_powershell(&shell)
|
||||
let cmd = '& ' . cmd
|
||||
endif
|
||||
return [batchfile, cmd]
|
||||
@@ -646,25 +736,25 @@ function! s:parse_options(arg)
|
||||
endif
|
||||
let opts.tag = a:arg
|
||||
elseif type == s:TYPE.dict
|
||||
call extend(opts, a:arg)
|
||||
for opt in ['branch', 'tag', 'commit', 'rtp', 'dir', 'as']
|
||||
if has_key(opts, opt)
|
||||
\ && (type(opts[opt]) != s:TYPE.string || empty(opts[opt]))
|
||||
if has_key(a:arg, opt)
|
||||
\ && (type(a:arg[opt]) != s:TYPE.string || empty(a:arg[opt]))
|
||||
throw printf(opt_errfmt, opt, 'string')
|
||||
endif
|
||||
endfor
|
||||
for opt in ['on', 'for']
|
||||
if has_key(opts, opt)
|
||||
\ && type(opts[opt]) != s:TYPE.list
|
||||
\ && (type(opts[opt]) != s:TYPE.string || empty(opts[opt]))
|
||||
if has_key(a:arg, opt)
|
||||
\ && type(a:arg[opt]) != s:TYPE.list
|
||||
\ && (type(a:arg[opt]) != s:TYPE.string || empty(a:arg[opt]))
|
||||
throw printf(opt_errfmt, opt, 'string or list')
|
||||
endif
|
||||
endfor
|
||||
if has_key(opts, 'do')
|
||||
\ && type(opts.do) != s:TYPE.funcref
|
||||
\ && (type(opts.do) != s:TYPE.string || empty(opts.do))
|
||||
if has_key(a:arg, 'do')
|
||||
\ && type(a:arg.do) != s:TYPE.funcref
|
||||
\ && (type(a:arg.do) != s:TYPE.string || empty(a:arg.do))
|
||||
throw printf(opt_errfmt, 'do', 'string or funcref')
|
||||
endif
|
||||
call extend(opts, a:arg)
|
||||
if has_key(opts, 'dir')
|
||||
let opts.dir = s:dirpath(s:plug_expand(opts.dir))
|
||||
endif
|
||||
@@ -720,7 +810,7 @@ function! s:syntax()
|
||||
syn match plugNumber /[0-9]\+[0-9.]*/ contained
|
||||
syn match plugBracket /[[\]]/ contained
|
||||
syn match plugX /x/ contained
|
||||
syn match plugDash /^-/
|
||||
syn match plugDash /^-\{1}\ /
|
||||
syn match plugPlus /^+/
|
||||
syn match plugStar /^*/
|
||||
syn match plugMessage /\(^- \)\@<=.*/
|
||||
@@ -738,6 +828,7 @@ function! s:syntax()
|
||||
syn match plugError /^x.*/
|
||||
syn region plugDeleted start=/^\~ .*/ end=/^\ze\S/
|
||||
syn match plugH2 /^.*:\n-\+$/
|
||||
syn match plugH2 /^-\{2,}/
|
||||
syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean
|
||||
hi def link plug1 Title
|
||||
hi def link plug2 Repeat
|
||||
@@ -850,7 +941,7 @@ function! s:prepare(...)
|
||||
call s:new_window()
|
||||
endif
|
||||
|
||||
nnoremap <silent> <buffer> q :if b:plug_preview==1<bar>pc<bar>endif<bar>bd<cr>
|
||||
nnoremap <silent> <buffer> q :call <SID>close_pane()<cr>
|
||||
if a:0 == 0
|
||||
call s:finish_bindings()
|
||||
endif
|
||||
@@ -872,6 +963,15 @@ function! s:prepare(...)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:close_pane()
|
||||
if b:plug_preview == 1
|
||||
pc
|
||||
let b:plug_preview = -1
|
||||
else
|
||||
bd
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:assign_name()
|
||||
" Assign buffer name
|
||||
let prefix = '[Plugins]'
|
||||
@@ -890,7 +990,7 @@ function! s:chsh(swap)
|
||||
set shell=sh
|
||||
endif
|
||||
if a:swap
|
||||
if &shell =~# 'powershell\(\.exe\)\?$' || &shell =~# 'pwsh$'
|
||||
if s:is_powershell(&shell)
|
||||
let &shellredir = '2>&1 | Out-File -Encoding UTF8 %s'
|
||||
elseif &shell =~# 'sh' || &shell =~# 'cmd\(\.exe\)\?$'
|
||||
set shellredir=>%s\ 2>&1
|
||||
@@ -991,10 +1091,11 @@ endfunction
|
||||
|
||||
function! s:checkout(spec)
|
||||
let sha = a:spec.commit
|
||||
let output = s:system(['git', 'rev-parse', 'HEAD'], a:spec.dir)
|
||||
if !v:shell_error && !s:hash_match(sha, s:lines(output)[0])
|
||||
let output = s:git_revision(a:spec.dir)
|
||||
if !empty(output) && !s:hash_match(sha, s:lines(output)[0])
|
||||
let credential_helper = s:git_version_requirement(2) ? '-c credential.helper= ' : ''
|
||||
let output = s:system(
|
||||
\ 'git fetch --depth 999999 && git checkout '.plug#shellescape(sha).' --', a:spec.dir)
|
||||
\ 'git '.credential_helper.'fetch --depth 999999 && git checkout '.plug#shellescape(sha).' --', a:spec.dir)
|
||||
endif
|
||||
return output
|
||||
endfunction
|
||||
@@ -1109,7 +1210,8 @@ function! s:update_impl(pull, force, args) abort
|
||||
normal! 2G
|
||||
silent! redraw
|
||||
|
||||
let s:clone_opt = []
|
||||
" Set remote name, overriding a possible user git config's clone.defaultRemoteName
|
||||
let s:clone_opt = ['--origin', 'origin']
|
||||
if get(g:, 'plug_shallow', 1)
|
||||
call extend(s:clone_opt, ['--depth', '1'])
|
||||
if s:git_version_requirement(1, 7, 10)
|
||||
@@ -1206,7 +1308,7 @@ function! s:update_finish()
|
||||
call s:log4(name, 'Checking out '.tag)
|
||||
let out = s:system('git checkout -q '.plug#shellescape(tag).' -- 2>&1', spec.dir)
|
||||
else
|
||||
let branch = get(spec, 'branch', 'master')
|
||||
let branch = s:git_origin_branch(spec)
|
||||
call s:log4(name, 'Merging origin/'.s:esc(branch))
|
||||
let out = s:system('git checkout -q '.plug#shellescape(branch).' -- 2>&1'
|
||||
\. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only '.plug#shellescape('origin/'.branch).' 2>&1')), spec.dir)
|
||||
@@ -1446,7 +1548,7 @@ while 1 " Without TCO, Vim stack is bound to explode
|
||||
let [error, _] = s:git_validate(spec, 0)
|
||||
if empty(error)
|
||||
if pull
|
||||
let cmd = ['git', 'fetch']
|
||||
let cmd = s:git_version_requirement(2) ? ['git', '-c', 'credential.helper=', 'fetch'] : ['git', 'fetch']
|
||||
if has_tag && !empty(globpath(spec.dir, '.git/shallow'))
|
||||
call extend(cmd, ['--depth', '99999999'])
|
||||
endif
|
||||
@@ -2130,7 +2232,7 @@ function! plug#shellescape(arg, ...)
|
||||
let script = get(opts, 'script', 1)
|
||||
if shell =~# 'cmd\(\.exe\)\?$'
|
||||
return s:shellesc_cmd(a:arg, script)
|
||||
elseif shell =~# 'powershell\(\.exe\)\?$' || shell =~# 'pwsh$'
|
||||
elseif s:is_powershell(shell)
|
||||
return s:shellesc_ps1(a:arg)
|
||||
endif
|
||||
return s:shellesc_sh(a:arg)
|
||||
@@ -2182,7 +2284,7 @@ function! s:system(cmd, ...)
|
||||
return system(a:cmd)
|
||||
endif
|
||||
let cmd = join(map(copy(a:cmd), 'plug#shellescape(v:val, {"shell": &shell, "script": 0})'))
|
||||
if &shell =~# 'powershell\(\.exe\)\?$'
|
||||
if s:is_powershell(&shell)
|
||||
let cmd = '& ' . cmd
|
||||
endif
|
||||
else
|
||||
@@ -2211,18 +2313,17 @@ endfunction
|
||||
function! s:git_validate(spec, check_branch)
|
||||
let err = ''
|
||||
if isdirectory(a:spec.dir)
|
||||
let result = s:lines(s:system('git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url', a:spec.dir))
|
||||
let result = [s:git_local_branch(a:spec.dir), s:git_origin_url(a:spec.dir)]
|
||||
let remote = result[-1]
|
||||
if v:shell_error
|
||||
if empty(remote)
|
||||
let err = join([remote, 'PlugClean required.'], "\n")
|
||||
elseif !s:compare_git_uri(remote, a:spec.uri)
|
||||
let err = join(['Invalid URI: '.remote,
|
||||
\ 'Expected: '.a:spec.uri,
|
||||
\ 'PlugClean required.'], "\n")
|
||||
elseif a:check_branch && has_key(a:spec, 'commit')
|
||||
let result = s:lines(s:system('git rev-parse HEAD 2>&1', a:spec.dir))
|
||||
let sha = result[-1]
|
||||
if v:shell_error
|
||||
let sha = s:git_revision(a:spec.dir)
|
||||
if empty(sha)
|
||||
let err = join(add(result, 'PlugClean required.'), "\n")
|
||||
elseif !s:hash_match(sha, a:spec.commit)
|
||||
let err = join([printf('Invalid HEAD (expected: %s, actual: %s)',
|
||||
@@ -2230,8 +2331,9 @@ function! s:git_validate(spec, check_branch)
|
||||
\ 'PlugUpdate required.'], "\n")
|
||||
endif
|
||||
elseif a:check_branch
|
||||
let branch = result[0]
|
||||
let current_branch = result[0]
|
||||
" Check tag
|
||||
let origin_branch = s:git_origin_branch(a:spec)
|
||||
if has_key(a:spec, 'tag')
|
||||
let tag = s:system_chomp('git describe --exact-match --tags HEAD 2>&1', a:spec.dir)
|
||||
if a:spec.tag !=# tag && a:spec.tag !~ '\*'
|
||||
@@ -2239,14 +2341,14 @@ function! s:git_validate(spec, check_branch)
|
||||
\ (empty(tag) ? 'N/A' : tag), a:spec.tag)
|
||||
endif
|
||||
" Check branch
|
||||
elseif a:spec.branch !=# branch
|
||||
elseif origin_branch !=# current_branch
|
||||
let err = printf('Invalid branch: %s (expected: %s). Try PlugUpdate.',
|
||||
\ branch, a:spec.branch)
|
||||
\ current_branch, origin_branch)
|
||||
endif
|
||||
if empty(err)
|
||||
let [ahead, behind] = split(s:lastline(s:system([
|
||||
\ 'git', 'rev-list', '--count', '--left-right',
|
||||
\ printf('HEAD...origin/%s', a:spec.branch)
|
||||
\ printf('HEAD...origin/%s', origin_branch)
|
||||
\ ], a:spec.dir)), '\t')
|
||||
if !v:shell_error && ahead
|
||||
if behind
|
||||
@@ -2254,11 +2356,11 @@ function! s:git_validate(spec, check_branch)
|
||||
" pushable (and probably not that messed up).
|
||||
let err = printf(
|
||||
\ "Diverged from origin/%s (%d commit(s) ahead and %d commit(s) behind!\n"
|
||||
\ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', a:spec.branch, ahead, behind)
|
||||
\ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', origin_branch, ahead, behind)
|
||||
else
|
||||
let err = printf("Ahead of origin/%s by %d commit(s).\n"
|
||||
\ .'Cannot update until local changes are pushed.',
|
||||
\ a:spec.branch, ahead)
|
||||
\ origin_branch, ahead)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
@@ -2519,26 +2621,34 @@ function! s:preview_commit()
|
||||
|
||||
let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7,9}')
|
||||
if empty(sha)
|
||||
return
|
||||
let name = matchstr(getline('.'), '^- \zs[^:]*\ze:$')
|
||||
if empty(name)
|
||||
return
|
||||
endif
|
||||
let title = 'HEAD@{1}..'
|
||||
let command = 'git diff --no-color HEAD@{1}'
|
||||
else
|
||||
let title = sha
|
||||
let command = 'git show --no-color --pretty=medium '.sha
|
||||
let name = s:find_name(line('.'))
|
||||
endif
|
||||
|
||||
let name = s:find_name(line('.'))
|
||||
if empty(name) || !has_key(g:plugs, name) || !isdirectory(g:plugs[name].dir)
|
||||
return
|
||||
endif
|
||||
|
||||
if exists('g:plug_pwindow') && !s:is_preview_window_open()
|
||||
execute g:plug_pwindow
|
||||
execute 'e' sha
|
||||
execute 'e' title
|
||||
else
|
||||
execute 'pedit' sha
|
||||
execute 'pedit' title
|
||||
wincmd P
|
||||
endif
|
||||
setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable
|
||||
setlocal previewwindow filetype=git buftype=nofile bufhidden=wipe nobuflisted modifiable
|
||||
let batchfile = ''
|
||||
try
|
||||
let [sh, shellcmdflag, shrd] = s:chsh(1)
|
||||
let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha
|
||||
let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && '.command
|
||||
if s:is_win
|
||||
let [batchfile, cmd] = s:batchfile(cmd)
|
||||
endif
|
||||
@@ -2588,20 +2698,23 @@ function! s:diff()
|
||||
endif
|
||||
call s:append_ul(2, origin ? 'Pending updates:' : 'Last update:')
|
||||
for [k, v] in plugs
|
||||
let range = origin ? '..origin/'.v.branch : 'HEAD@{1}..'
|
||||
let cmd = ['git', 'log', '--graph', '--color=never']
|
||||
if s:git_version_requirement(2, 10, 0)
|
||||
call add(cmd, '--no-show-signature')
|
||||
endif
|
||||
call extend(cmd, ['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range])
|
||||
if has_key(v, 'rtp')
|
||||
call extend(cmd, ['--', v.rtp])
|
||||
endif
|
||||
let diff = s:system_chomp(cmd, v.dir)
|
||||
if !empty(diff)
|
||||
let ref = has_key(v, 'tag') ? (' (tag: '.v.tag.')') : has_key(v, 'commit') ? (' '.v.commit) : ''
|
||||
call append(5, extend(['', '- '.k.':'.ref], map(s:lines(diff), 's:format_git_log(v:val)')))
|
||||
let cnts[origin] += 1
|
||||
let branch = s:git_origin_branch(v)
|
||||
if len(branch)
|
||||
let range = origin ? '..origin/'.branch : 'HEAD@{1}..'
|
||||
let cmd = ['git', 'log', '--graph', '--color=never']
|
||||
if s:git_version_requirement(2, 10, 0)
|
||||
call add(cmd, '--no-show-signature')
|
||||
endif
|
||||
call extend(cmd, ['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range])
|
||||
if has_key(v, 'rtp')
|
||||
call extend(cmd, ['--', v.rtp])
|
||||
endif
|
||||
let diff = s:system_chomp(cmd, v.dir)
|
||||
if !empty(diff)
|
||||
let ref = has_key(v, 'tag') ? (' (tag: '.v.tag.')') : has_key(v, 'commit') ? (' '.v.commit) : ''
|
||||
call append(5, extend(['', '- '.k.':'.ref], map(s:lines(diff), 's:format_git_log(v:val)')))
|
||||
let cnts[origin] += 1
|
||||
endif
|
||||
endif
|
||||
let bar .= '='
|
||||
call s:progress_bar(2, bar, len(total))
|
||||
@@ -2661,9 +2774,9 @@ function! s:snapshot(force, ...) abort
|
||||
1
|
||||
let anchor = line('$') - 3
|
||||
let names = sort(keys(filter(copy(g:plugs),
|
||||
\'has_key(v:val, "uri") && !has_key(v:val, "commit") && isdirectory(v:val.dir)')))
|
||||
\'has_key(v:val, "uri") && isdirectory(v:val.dir)')))
|
||||
for name in reverse(names)
|
||||
let sha = s:system_chomp(['git', 'rev-parse', '--short', 'HEAD'], g:plugs[name].dir)
|
||||
let sha = has_key(g:plugs[name], 'commit') ? g:plugs[name].commit : s:git_revision(g:plugs[name].dir)
|
||||
if !empty(sha)
|
||||
call append(anchor, printf("silent! let g:plugs['%s'].commit = '%s'", name, sha))
|
||||
redraw
|
||||
162
.vim/colors/campo-dark-blue.vim
Normal file
162
.vim/colors/campo-dark-blue.vim
Normal file
@@ -0,0 +1,162 @@
|
||||
" A simple dark vim colorscheme.
|
||||
" Created by Michael Campagnaro (https://git.michael.is)
|
||||
|
||||
if has('termguicolors')
|
||||
" Supports 24-bit color range
|
||||
set termguicolors
|
||||
let g:campo_theme_use_rainbow_parens = 0
|
||||
else
|
||||
echoerr "This theme requires 'termguicolors' support!"
|
||||
endif
|
||||
|
||||
if !has("gui_running") && &t_Co != 88 && &t_Co != 256
|
||||
echoerr "Don't have expected color support!"
|
||||
endif
|
||||
|
||||
set background=dark
|
||||
hi clear
|
||||
syntax reset
|
||||
|
||||
source $HOME/.vim/colors/utils
|
||||
let g:colors_name = "campo-dark-blue"
|
||||
|
||||
" Shared colors
|
||||
let s:blue = "3699cc"
|
||||
let s:purple = "ce93d8"
|
||||
let s:grey = "b0bec5"
|
||||
let s:orange = "ffb74d"
|
||||
let s:yellow = "fff176"
|
||||
let s:green = "88b888"
|
||||
let s:red = "ef2929"
|
||||
let s:text = "f1f1e8" " A majority of the syntax will use this.
|
||||
let s:bg = "072730"
|
||||
let s:select = "546e8f"
|
||||
let s:window = "37474f"
|
||||
let s:comment = "5dea82"
|
||||
let s:tab = "03404a"
|
||||
let s:error = "e40e0e"
|
||||
let s:proc = "0eefcb"
|
||||
let s:warn = "dcd53e"
|
||||
let s:spell = "aaf53e"
|
||||
|
||||
" Vim
|
||||
call X("Normal", s:text, s:bg, "")
|
||||
call X("LineNr", s:grey, "", "")
|
||||
call X("NonText", s:text, "", "")
|
||||
call X("SpecialKey", s:blue, "", "")
|
||||
call X("Search", s:text, s:select, "")
|
||||
call X("TabLineSel", s:text, s:bg, "bold")
|
||||
call X("TabLine", "dddddd", s:tab, "none")
|
||||
call X("TabLineFill", "", s:tab, "none") " The tab line region that doesn't contain tab entries.
|
||||
call X("StatusLine", s:window, s:text, "reverse")
|
||||
call X("StatusLineNC", s:window, s:comment, "reverse")
|
||||
call X("VertSplit", s:window, s:window, "none")
|
||||
call X("Visual", "", s:select, "")
|
||||
call X("Directory", s:blue, "", "")
|
||||
call X("ModeMsg", s:green, "", "")
|
||||
call X("MoreMsg", s:green, "", "")
|
||||
call X("Question", s:green, "", "")
|
||||
call X("MatchParen", "", s:select, "")
|
||||
call X("Folded", s:comment, s:bg, "")
|
||||
call X("FoldColumn", s:comment, s:bg, "")
|
||||
call X("SpellBad", s:spell, s:bg, "bold")
|
||||
call X("SpellCap", s:text, s:bg, "") " A word that should start with a capital
|
||||
call X("SpellLocal", s:spell, s:bg, "bold") " Correctly spelled but used in another region.
|
||||
call X("SpellRare", s:text, s:bg, "") " A correctly spelled that is hardly ever used. Don't care about this.
|
||||
call X("ErrorMsg", s:error, s:bg, "bold")
|
||||
if version >= 700
|
||||
call X("PMenu", s:text, s:select, "none") " Autocompletion menu
|
||||
call X("PMenuSel", s:text, "027990", "bold") " Selected autocompletion item
|
||||
call X("SignColumn", "", s:bg, "none")
|
||||
call X("CursorLine", "", "022f36", "none") " Horizontal line at the cursor.
|
||||
call X("CursorColumn", "", "022c33", "none") " Vertical line at the cursor.
|
||||
end
|
||||
if version >= 703
|
||||
call X("ColorColumn", "", "022c33", "none") " Vertical line set by colorcolumn option.
|
||||
end
|
||||
|
||||
" Standard Highlighting
|
||||
call X("Comment", s:comment, "", "")
|
||||
call X("Title", s:comment, "", "")
|
||||
call X("Cursor", "", s:text, "")
|
||||
call X("Identifier", s:grey, "", "none")
|
||||
call X("Statement", s:text, "", "") " 'return', 'goto', 'case', 'break', etc
|
||||
call X("Conditional", s:text, "", "")
|
||||
call X("Repeat", s:text, "", "") " 'for' and 'while'
|
||||
call X("Structure", "ae90ea", "", "")
|
||||
call X("Function", s:proc, "", "")
|
||||
call X("Constant", s:text, "", "") " Constants, e.g. SOME_CONST
|
||||
call X("Boolean", s:text, "", "") " true, false
|
||||
call X("String", s:text, "", "")
|
||||
call X("Special", s:text, "", "")
|
||||
call X("PreProc", s:text, "", "")
|
||||
call X("Operator", s:text, "", "none")
|
||||
call X("Type", s:text, "", "") " Data types
|
||||
call X("Define", "a5bce4", "", "none")
|
||||
call X("Include", s:text, "", "") " #include in C/C++
|
||||
call X("Number", s:text, "", "")
|
||||
|
||||
" Notes
|
||||
call X("Todo", "b8fbb0", s:bg, "underline")
|
||||
call X("Bugs", "d8fbb0", s:bg, "standout")
|
||||
call X("Notes", "ffffff", s:bg, "standout")
|
||||
call X("Notices", s:warn, s:bg, "bold")
|
||||
|
||||
" Build markers
|
||||
call X("BuildError", s:error, s:bg, "bold")
|
||||
call X("BuildWarn", s:warn, s:bg, "bold")
|
||||
call X("BuildInfo", s:text, s:bg, "bold")
|
||||
|
||||
" Jai Highlighting
|
||||
call X("jaiVariableDeclaration", s:text, "", "")
|
||||
call X("jaiTagNote", s:orange, "", "bold")
|
||||
|
||||
" airblade/vim-gitgutter
|
||||
call X("GitGutterAdd", s:green, "", "")
|
||||
call X("GitGutterDelete", s:red, "", "")
|
||||
call X("GitGutterChange", s:yellow, "", "")
|
||||
call X("GitGutterChangeDelete", s:orange, "", "")
|
||||
|
||||
" C Highlighting
|
||||
call X("cType", s:text, "", "")
|
||||
call X("cStorageClass", s:text, "", "")
|
||||
call X("cConditional", s:text, "", "")
|
||||
call X("cRepeat", s:text, "", "")
|
||||
|
||||
" Python Highlighting
|
||||
call X("pythonInclude", s:red, "", "")
|
||||
call X("pythonStatement", s:blue, "", "")
|
||||
call X("pythonConditional", s:purple, "", "")
|
||||
call X("pythonRepeat", s:purple, "", "")
|
||||
call X("pythonException", s:purple, "", "")
|
||||
call X("pythonFunction", s:proc, "", "")
|
||||
call X("pythonSelf", s:grey, "", "")
|
||||
call X("pythonOperator", s:purple, "", "")
|
||||
call X("pythonExtraOperator", s:purple, "", "")
|
||||
call X("pythonClass", s:proc, "", "")
|
||||
call X("pythonDecorator", s:orange, "", "")
|
||||
call X("pythonDocstring", s:comment, "", "")
|
||||
call X("pythonBuiltinObj", s:yellow, "", "")
|
||||
call X("pythonBuiltinType", s:orange, "", "")
|
||||
call X("pythonNumber", s:orange, "", "")
|
||||
|
||||
" JS Highlighting
|
||||
call X("javaScriptBraces", s:text, "", "")
|
||||
call X("javaScriptFunction", s:purple, "", "")
|
||||
call X("javaScriptConditional", s:purple, "", "")
|
||||
call X("javaScriptRepeat", s:purple, "", "")
|
||||
call X("javaScriptNumber", s:orange, "", "")
|
||||
call X("javaScriptMember", s:orange, "", "")
|
||||
|
||||
" HTML Highlighting
|
||||
call X("htmlTag", s:text, "", "")
|
||||
call X("htmlTagName", s:text, "", "")
|
||||
call X("htmlArg", s:text, "", "")
|
||||
call X("htmlScriptTag", s:blue, "", "")
|
||||
|
||||
" Diff Highlighting
|
||||
call X("DiffAdd", s:window, s:green, "none")
|
||||
call X("DiffDelete", s:window, s:red, "none")
|
||||
call X("DiffChange", s:window, s:yellow, "none")
|
||||
call X("DiffText", s:bg, s:yellow, "none")
|
||||
|
||||
@@ -447,9 +447,6 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256
|
||||
call <SID>X("bladeKeyword", s:blue, "", "")
|
||||
|
||||
" Diff Highlighting
|
||||
call <SID>X("diffAdded", "", s:green, "none")
|
||||
call <SID>X("diffRemoved", "", s:red, "none")
|
||||
call <SID>X("diffChanged", "", s:yellow, "none")
|
||||
call <SID>X("DiffAdd", s:window, s:green, "none")
|
||||
call <SID>X("DiffDelete", s:window, s:red, "none")
|
||||
call <SID>X("DiffChange", s:window, s:yellow, "none")
|
||||
@@ -414,9 +414,6 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256
|
||||
call <SID>X("bladeKeyword", s:blue, "", "")
|
||||
|
||||
" Diff Highlighting
|
||||
call <SID>X("diffAdded", "", s:green, "none")
|
||||
call <SID>X("diffRemoved", "", s:red, "none")
|
||||
call <SID>X("diffChanged", "", s:yellow, "none")
|
||||
call <SID>X("DiffAdd", s:window, s:green, "none")
|
||||
call <SID>X("DiffDelete", s:window, s:red, "none")
|
||||
call <SID>X("DiffChange", s:window, s:yellow, "none")
|
||||
@@ -432,9 +432,6 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256
|
||||
call <SID>X("bladeKeyword", s:blue, "", "")
|
||||
|
||||
" Diff Highlighting
|
||||
call <SID>X("diffAdded", "", s:green, "none")
|
||||
call <SID>X("diffRemoved", "", s:red, "none")
|
||||
call <SID>X("diffChanged", "", s:yellow, "none")
|
||||
call <SID>X("DiffAdd", s:window, s:green, "none")
|
||||
call <SID>X("DiffDelete", s:window, s:red, "none")
|
||||
call <SID>X("DiffChange", s:window, s:yellow, "none")
|
||||
@@ -45,9 +45,9 @@ if has("gui_running") || &t_Co == 256
|
||||
hi PmenuSel cterm=bold,reverse ctermfg=250 ctermbg=black gui=reverse guifg=#bcbcbc guibg=#0a0a0a
|
||||
hi SpecialKey cterm=NONE ctermfg=16 ctermbg=255 gui=NONE guifg=#eeeeee guibg=#0a0a0a
|
||||
hi MatchParen cterm=bold ctermfg=white ctermbg=black gui=NONE guifg=#bcbcbc guibg=#454545
|
||||
hi CursorLine cterm=NONE ctermfg=NONE ctermbg=233 gui=NONE guifg=NONE guibg=#222222
|
||||
hi CursorColumn cterm=NONE ctermfg=NONE ctermbg=233 gui=NONE guifg=NONE guibg=#222222
|
||||
hi ColorColumn cterm=NONE ctermfg=NONE ctermbg=255 gui=NONE guifg=NONE guibg=#222222 " The column line set by colorcolumn
|
||||
hi CursorLine cterm=NONE ctermfg=NONE ctermbg=233 gui=NONE guifg=NONE guibg=#111111
|
||||
hi CursorColumn cterm=NONE ctermfg=NONE ctermbg=233 gui=NONE guifg=NONE guibg=#111111
|
||||
hi ColorColumn cterm=NONE ctermfg=NONE ctermbg=255 gui=NONE guifg=NONE guibg=#171717 " The column line set by colorcolumn
|
||||
hi StatusLine cterm=bold,reverse ctermfg=245 ctermbg=black gui=bold,reverse guifg=#8a8a8a guibg=#0a0a0a
|
||||
hi StatusLineNC cterm=reverse ctermfg=236 ctermbg=black gui=reverse guifg=#303030 guibg=#0a0a0a
|
||||
hi Visual cterm=reverse ctermfg=250 ctermbg=black gui=reverse guifg=#bcbcbc guibg=#0a0a0a
|
||||
@@ -81,8 +81,6 @@ highlight! link Todo Keyword
|
||||
highlight! link Label Keyword
|
||||
highlight! link Define Keyword
|
||||
highlight! link DiffAdd Keyword
|
||||
highlight! link diffAdded Keyword
|
||||
highlight! link diffCommon Keyword
|
||||
highlight! link Directory Keyword
|
||||
highlight! link PreCondit Keyword
|
||||
highlight! link PreProc Keyword
|
||||
@@ -101,11 +99,9 @@ highlight! link iCursor SpecialKey
|
||||
highlight! link SpellLocal SpellCap
|
||||
highlight! link NonText NonText
|
||||
highlight! link DiffDelete Comment
|
||||
highlight! link diffRemoved Comment
|
||||
highlight! link PmenuSbar Visual
|
||||
highlight! link VisualNOS Visual
|
||||
highlight! link VertSplit VertSplit
|
||||
highlight! link Cursor StatusLine
|
||||
highlight! link Underlined SpellRare
|
||||
highlight! link rstEmphasis SpellRare
|
||||
highlight! link diffChanged DiffChange
|
||||
@@ -79,8 +79,6 @@ highlight! link Todo Keyword
|
||||
highlight! link Label Keyword
|
||||
highlight! link Define Keyword
|
||||
highlight! link DiffAdd Keyword
|
||||
highlight! link diffAdded Keyword
|
||||
highlight! link diffCommon Keyword
|
||||
highlight! link Directory Keyword
|
||||
highlight! link PreCondit Keyword
|
||||
highlight! link PreProc Keyword
|
||||
@@ -100,10 +98,8 @@ highlight! link SpellLocal SpellCap
|
||||
highlight! link LineNr Comment
|
||||
highlight! link NonText NonText
|
||||
highlight! link DiffDelete Comment
|
||||
highlight! link diffRemoved Comment
|
||||
highlight! link VisualNOS Visual
|
||||
highlight! link VertSplit VertSplit
|
||||
highlight! link Cursor StatusLine
|
||||
highlight! link Underlined SpellRare
|
||||
highlight! link rstEmphasis SpellRare
|
||||
highlight! link diffChanged DiffChange
|
||||
@@ -1,5 +1,5 @@
|
||||
" A simple light colorscheme.
|
||||
" Maintainer: Michael Campagnaro <mikecampo@gmail.com>
|
||||
" Maintainer: Michael Campagnaro
|
||||
" Version: 1.0
|
||||
"
|
||||
" Adapted from https://github.com/tek256/simple-dark
|
||||
@@ -81,8 +81,6 @@ highlight! link Todo Keyword
|
||||
highlight! link Label Keyword
|
||||
highlight! link Define Keyword
|
||||
highlight! link DiffAdd Keyword
|
||||
highlight! link diffAdded Keyword
|
||||
highlight! link diffCommon Keyword
|
||||
highlight! link Directory Keyword
|
||||
highlight! link PreCondit Keyword
|
||||
highlight! link PreProc Keyword
|
||||
@@ -102,10 +100,8 @@ highlight! link SpellLocal SpellCap
|
||||
highlight! link LineNr Comment
|
||||
highlight! link NonText NonText
|
||||
highlight! link DiffDelete Comment
|
||||
highlight! link diffRemoved Comment
|
||||
highlight! link VisualNOS Visual
|
||||
highlight! link VertSplit VertSplit
|
||||
highlight! link Cursor StatusLine
|
||||
highlight! link Underlined SpellRare
|
||||
highlight! link rstEmphasis SpellRare
|
||||
highlight! link diffChanged DiffChange
|
||||
@@ -377,9 +377,6 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256
|
||||
call <SID>X("htmlScriptTag", s:blue, "", "")
|
||||
|
||||
" Diff Highlighting
|
||||
call <SID>X("diffAdded", "", s:green, "none")
|
||||
call <SID>X("diffRemoved", "", s:red, "none")
|
||||
call <SID>X("diffChanged", "", s:yellow, "none")
|
||||
call <SID>X("DiffAdd", s:window, s:green, "none")
|
||||
call <SID>X("DiffDelete", s:window, s:red, "none")
|
||||
call <SID>X("DiffChange", s:window, s:yellow, "none")
|
||||
209
.vim/colors/utils
Normal file
209
.vim/colors/utils
Normal file
@@ -0,0 +1,209 @@
|
||||
" Hex color conversion functions are from https://github.com/vim-scripts/desert256.vim/blob/master/colors/desert256.vim
|
||||
|
||||
" Returns an approximate grey index for the given grey level
|
||||
function! GreyNumber(x)
|
||||
if &t_Co == 88
|
||||
if a:x < 23
|
||||
return 0
|
||||
elseif a:x < 69
|
||||
return 1
|
||||
elseif a:x < 103
|
||||
return 2
|
||||
elseif a:x < 127
|
||||
return 3
|
||||
elseif a:x < 150
|
||||
return 4
|
||||
elseif a:x < 173
|
||||
return 5
|
||||
elseif a:x < 196
|
||||
return 6
|
||||
elseif a:x < 219
|
||||
return 7
|
||||
elseif a:x < 243
|
||||
return 8
|
||||
else
|
||||
return 9
|
||||
endif
|
||||
else
|
||||
if a:x < 14
|
||||
return 0
|
||||
else
|
||||
let l:n = (a:x - 8) / 10
|
||||
let l:m = (a:x - 8) % 10
|
||||
if l:m < 5
|
||||
return l:n
|
||||
else
|
||||
return l:n + 1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Returns the actual grey level represented by the grey index
|
||||
function! GreyLevel(n)
|
||||
if &t_Co == 88
|
||||
if a:n == 0
|
||||
return 0
|
||||
elseif a:n == 1
|
||||
return 46
|
||||
elseif a:n == 2
|
||||
return 92
|
||||
elseif a:n == 3
|
||||
return 115
|
||||
elseif a:n == 4
|
||||
return 139
|
||||
elseif a:n == 5
|
||||
return 162
|
||||
elseif a:n == 6
|
||||
return 185
|
||||
elseif a:n == 7
|
||||
return 208
|
||||
elseif a:n == 8
|
||||
return 231
|
||||
else
|
||||
return 255
|
||||
endif
|
||||
else
|
||||
if a:n == 0
|
||||
return 0
|
||||
else
|
||||
return 8 + (a:n * 10)
|
||||
endif
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Returns the palette index for the given grey index
|
||||
function! GreyColor(n)
|
||||
if &t_Co == 88
|
||||
if a:n == 0
|
||||
return 16
|
||||
elseif a:n == 9
|
||||
return 79
|
||||
else
|
||||
return 79 + a:n
|
||||
endif
|
||||
else
|
||||
if a:n == 0
|
||||
return 16
|
||||
elseif a:n == 25
|
||||
return 231
|
||||
else
|
||||
return 231 + a:n
|
||||
endif
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Returns an approximate colour index for the given colour level
|
||||
function! RGBNumber(x)
|
||||
if &t_Co == 88
|
||||
if a:x < 69
|
||||
return 0
|
||||
elseif a:x < 172
|
||||
return 1
|
||||
elseif a:x < 230
|
||||
return 2
|
||||
else
|
||||
return 3
|
||||
endif
|
||||
else
|
||||
if a:x < 75
|
||||
return 0
|
||||
else
|
||||
let l:n = (a:x - 55) / 40
|
||||
let l:m = (a:x - 55) % 40
|
||||
if l:m < 20
|
||||
return l:n
|
||||
else
|
||||
return l:n + 1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Returns the actual colour level for the given colour index
|
||||
function! RGBLevel(n)
|
||||
if &t_Co == 88
|
||||
if a:n == 0
|
||||
return 0
|
||||
elseif a:n == 1
|
||||
return 139
|
||||
elseif a:n == 2
|
||||
return 205
|
||||
else
|
||||
return 255
|
||||
endif
|
||||
else
|
||||
if a:n == 0
|
||||
return 0
|
||||
else
|
||||
return 55 + (a:n * 40)
|
||||
endif
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Returns the palette index for the given R/G/B colour indices
|
||||
function! RGBColor(x, y, z)
|
||||
if &t_Co == 88
|
||||
return 16 + (a:x * 16) + (a:y * 4) + a:z
|
||||
else
|
||||
return 16 + (a:x * 36) + (a:y * 6) + a:z
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Returns the palette index to approximate the given R/G/B colour levels
|
||||
function! Color(r, g, b)
|
||||
" Get the closest grey
|
||||
let l:gx = GreyNumber(a:r)
|
||||
let l:gy = GreyNumber(a:g)
|
||||
let l:gz = GreyNumber(a:b)
|
||||
|
||||
" Get the closest colour
|
||||
let l:x = RGBNumber(a:r)
|
||||
let l:y = RGBNumber(a:g)
|
||||
let l:z = RGBNumber(a:b)
|
||||
|
||||
if l:gx == l:gy && l:gy == l:gz
|
||||
" There are two possibilities
|
||||
let l:dgr = GreyLevel(l:gx) - a:r
|
||||
let l:dgg = GreyLevel(l:gy) - a:g
|
||||
let l:dgb = GreyLevel(l:gz) - a:b
|
||||
let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb)
|
||||
let l:dr = RGBLevel(l:gx) - a:r
|
||||
let l:dg = RGBLevel(l:gy) - a:g
|
||||
let l:db = RGBLevel(l:gz) - a:b
|
||||
let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db)
|
||||
if l:dgrey < l:drgb
|
||||
" Use the grey
|
||||
return GreyColor(l:gx)
|
||||
else
|
||||
" Use the colour
|
||||
return RGBColor(l:x, l:y, l:z)
|
||||
endif
|
||||
else
|
||||
" Only one possibility
|
||||
return RGBColor(l:x, l:y, l:z)
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Returns the palette index to approximate the 'rrggbb' hex string
|
||||
function! RGB(rgb)
|
||||
let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0
|
||||
let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0
|
||||
let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0
|
||||
|
||||
return Color(l:r, l:g, l:b)
|
||||
endfun
|
||||
|
||||
" Sets the highlighting for the given group
|
||||
function! X(group, fg, bg, attr)
|
||||
if a:fg != ""
|
||||
exec "hi " . a:group . " guifg=#" . a:fg . " ctermfg=" . RGB(a:fg)
|
||||
endif
|
||||
if a:bg != ""
|
||||
exec "hi " . a:group . " guibg=#" . a:bg . " ctermbg=" . RGB(a:bg)
|
||||
endif
|
||||
if a:attr != ""
|
||||
exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr
|
||||
endif
|
||||
endfun
|
||||
|
||||
0
vim/scripts/scmindent.rkt → .vim/scripts/scmindent.rkt
Executable file → Normal file
0
vim/scripts/scmindent.rkt → .vim/scripts/scmindent.rkt
Executable file → Normal file
@@ -266,3 +266,12 @@ throughs
|
||||
throughs
|
||||
incentivise
|
||||
malware
|
||||
foofy
|
||||
memcpy
|
||||
strlen
|
||||
u8
|
||||
s64
|
||||
Sculpey
|
||||
grey
|
||||
googly
|
||||
favour
|
||||
BIN
.vim/spell/en.utf-8.add.spl
Normal file
BIN
.vim/spell/en.utf-8.add.spl
Normal file
Binary file not shown.
11
README.md
11
README.md
@@ -1,11 +0,0 @@
|
||||
# dotfiles
|
||||
|
||||
Various dotfiles and misc configs. Some of it is customized around my system setup
|
||||
(like aliases pointing to paths) but you should be able to easily remove that stuff.
|
||||
|
||||
## Installing
|
||||
|
||||
There is an `install` script that facilitates the setup, however it's been a while since I did a
|
||||
full system setup and this script may not be fully complete. An alternative method is to manually
|
||||
symlink files in the root directory. OS specific configs are in their respective folders.
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
use_gpu=$1
|
||||
filename=$(basename -- "$2")
|
||||
output_name="$3"
|
||||
start_time="$4"
|
||||
end_time="$5"
|
||||
|
||||
if [[ $use_gpu == "" || $2 == "" || $output_name == "" || $start_time == "" || $end_time == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <use-gpu (1|0)> <filename> <output name> <start time HH:MM:SS> <end time HH:MM:SS>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Found the following to work best with vids containing text (e.g. programming vid): 25 for CPU encoding and 27 for GPU.
|
||||
use_crf=25
|
||||
if [[ $use_gpu -eq 1 ]]; then
|
||||
use_crf=27
|
||||
fi
|
||||
|
||||
compress-video-with-crf $use_gpu $use_crf "$filename" "$output_name" "$start_time" "$end_time"
|
||||
|
||||
16
bin/vim-pull
16
bin/vim-pull
@@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copies vim data from the home directory to the dotfiles repo.
|
||||
|
||||
set -e
|
||||
|
||||
src="$HOME/.vim"
|
||||
dest="$HOME/.dotfiles/vim/"
|
||||
|
||||
if [ -d $src ]; then
|
||||
[ -d "$src/spell" ] && echo "Syncing user dictionary" && cp -r "$src/spell" $dest
|
||||
[ -d "$src/colors" ] && echo "Syncing user colors" && cp -r "$src/colors" $dest
|
||||
[ -d "$src/after" ] && echo "Syncing after directory" && cp -r "$src/after" $dest
|
||||
[ -d "$src/ftdetect" ] && echo "Syncing ftdetect" && cp -r "$src/ftdetect" $dest
|
||||
[ -d "$src/autoload" ] && echo "Syncing autoload" && cp -r "$src/autoload" $dest
|
||||
fi
|
||||
16
bin/vim-push
16
bin/vim-push
@@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copies vim data from the dotfiles repo to the home directory.
|
||||
|
||||
set -e
|
||||
|
||||
src="$HOME/.dotfiles/vim"
|
||||
dest="$HOME/.vim/"
|
||||
|
||||
if [ -d $src ]; then
|
||||
[ -d "$src/spell" ] && echo "Syncing user dictionary" && cp -r "$src/spell" $dest
|
||||
[ -d "$src/colors" ] && echo "Syncing user colors" && cp -r "$src/colors" $dest
|
||||
[ -d "$src/after" ] && echo "Syncing after directory" && cp -r "$src/after" $dest
|
||||
[ -d "$src/ftdetect" ] && echo "Syncing ftdetect" && cp -r "$src/ftdetect" $dest
|
||||
[ -d "$src/autoload" ] && echo "Syncing autoload" && cp -r "$src/autoload" $dest
|
||||
fi
|
||||
21
dotfiles/.editorconfig
Normal file
21
dotfiles/.editorconfig
Normal file
@@ -0,0 +1,21 @@
|
||||
# EditorConfig helps developers define and maintain consistent
|
||||
# coding styles # between different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.bat]
|
||||
end_of_line = crlf
|
||||
|
||||
[*.tsv]
|
||||
indent_style = tab
|
||||
|
||||
32
dotfiles/README.md
Normal file
32
dotfiles/README.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# dotfiles
|
||||
|
||||
Various dotfiles and misc configs. Some of it is customized around my system
|
||||
setup (like aliases pointing to paths) but you should be able to easily remove
|
||||
that stuff.
|
||||
|
||||
This unpacks files one directory back, which is assumed to be your home
|
||||
directory. The gitignore ignores all files by default. If you want to add a new
|
||||
file this you need to add the `-f` flag to the git add command. This setup was
|
||||
inspired by Gary Bernhardt and https://gist.github.com/meleu/053275b6842646b95491bf1af4a6ca0e
|
||||
|
||||
## Installing
|
||||
|
||||
```bash
|
||||
# Go to your home directory.
|
||||
cd ~
|
||||
|
||||
# Clone the repo with the "--no-checkout" option (so we can checkout the files in our home directory)
|
||||
git clone --no-checkout <repo_url>/dotfiles.git
|
||||
|
||||
# Go to the created directory and change the worktree to the home direcory.
|
||||
cd dotfiles
|
||||
git config core.worktree '../../'
|
||||
|
||||
# Checkout the files. This will overwrite existing dotfiles with the same name.
|
||||
git reset --hard origin/master
|
||||
```
|
||||
|
||||
If you want to install optional OS specific stuff, like various packages, run the `install` script in this folder.
|
||||
|
||||
OS specific configs are in their respective folders.
|
||||
|
||||
107
dotfiles/bin/antimalware-service-disable.bat
Normal file
107
dotfiles/bin/antimalware-service-disable.bat
Normal file
@@ -0,0 +1,107 @@
|
||||
@setlocal enableextensions enabledelayedexpansion
|
||||
@echo off
|
||||
|
||||
rem Make sure we're running as admin. Got this garbage from https://stackoverflow.com/a/40388766
|
||||
if not "%1"=="am_admin" (
|
||||
powershell -Command "Start-Process -Verb RunAs -FilePath '%0' -ArgumentList 'am_admin'"
|
||||
exit /b
|
||||
)
|
||||
|
||||
rem USE AT OWN RISK AS IS WITHOUT WARRANTY OF ANY KIND !!!!!
|
||||
rem NOTE: Defender may see this file as malware, so you will likely need to exclude this before things can be disabled.
|
||||
rem
|
||||
rem Modified version of
|
||||
rem https://raw.githubusercontent.com/mattreecebentley/win10_disable_defender/main/win10_enable_defender.bat
|
||||
rem https://gist.github.com/xezrunner/a7a42dbc1096a40b0c78f09488fe5a2b
|
||||
|
||||
reg query HKLM\SYSTEM\Setup /v DisabledDefenderServices | find "0x1"
|
||||
if %errorlevel% == 0 goto already_patched
|
||||
|
||||
echo.
|
||||
echo Please note that Defender can only be disabled in Win10 v2004 and upwards if Tamper Protection is disabled.
|
||||
echo This setting can be found in Window settings (hint: search for 'tamper'). Please do this now and then,
|
||||
pause
|
||||
|
||||
echo.
|
||||
echo Disabling Windows Defender
|
||||
rem from: https://pastebin.com/kYCVzZPz
|
||||
rem Disable Tamper Protection First - on WIn10 vers which allow for this (not from 2004 onwards)
|
||||
reg add "HKLM\Software\Microsoft\Windows Defender\Features" /v "TamperProtection" /t REG_DWORD /d "0" /f
|
||||
|
||||
rem To disable System Guard Runtime Monitor Broker
|
||||
rem reg add "HKLM\System\CurrentControlSet\Services\SgrmBroker" /v "Start" /t REG_DWORD /d "4" /f
|
||||
|
||||
rem To disable Windows Defender Security Center include this
|
||||
rem reg add "HKLM\System\CurrentControlSet\Services\SecurityHealthService" /v "Start" /t REG_DWORD /d "4" /f
|
||||
|
||||
echo.
|
||||
echo Disable Real-time protection
|
||||
reg delete "HKLM\Software\Policies\Microsoft\Windows Defender" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender" /v "DisableAntiSpyware" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender" /v "DisableAntiVirus" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\MpEngine" /v "MpEnablePus" /t REG_DWORD /d "0" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v "DisableBehaviorMonitoring" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v "DisableIOAVProtection" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v "DisableOnAccessProtection" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v "DisableRealtimeMonitoring" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v "DisableRoutinelyTakingAction" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v "DisableScanOnRealtimeEnable" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Reporting" /v "DisableEnhancedNotifications" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\SpyNet" /v "DisableBlockAtFirstSeen" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\SpyNet" /v "SpynetReporting" /t REG_DWORD /d "0" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\SpyNet" /v "SubmitSamplesConsent" /t REG_DWORD /d "2" /f
|
||||
|
||||
echo.
|
||||
echo Disable Logging
|
||||
reg add "HKLM\System\CurrentControlSet\Control\WMI\Autologger\DefenderApiLogger" /v "Start" /t REG_DWORD /d "0" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Control\WMI\Autologger\DefenderAuditLogger" /v "Start" /t REG_DWORD /d "0" /f
|
||||
|
||||
echo.
|
||||
echo Disable WD Tasks
|
||||
schtasks /Change /TN "Microsoft\Windows\ExploitGuard\ExploitGuard MDM policy Refresh" /Disable
|
||||
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Cache Maintenance" /Disable
|
||||
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Cleanup" /Disable
|
||||
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Scheduled Scan" /Disable
|
||||
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Verification" /Disable
|
||||
|
||||
echo.
|
||||
echo Disable WD systray icon
|
||||
reg delete "HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run" /v "SecurityHealth" /f
|
||||
reg delete "HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /v "SecurityHealth" /f
|
||||
|
||||
echo.
|
||||
echo Remove WD context menu
|
||||
reg delete "HKCR\*\shellex\ContextMenuHandlers\EPP" /f
|
||||
reg delete "HKCR\Directory\shellex\ContextMenuHandlers\EPP" /f
|
||||
reg delete "HKCR\Drive\shellex\ContextMenuHandlers\EPP" /f
|
||||
|
||||
echo.
|
||||
echo Disable WD services
|
||||
reg add HKLM\SYSTEM\CurrentControlSet\Services\wscsvc /v "Start" /t REG_DWORD /d "4" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\WdBoot" /v "Start" /t REG_DWORD /d "4" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\wdFilter" /v "Start" /t REG_DWORD /d "4" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\WdNisDrv" /v "Start" /t REG_DWORD /d "4" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\WdNisSvc" /v "Start" /t REG_DWORD /d "4" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\WinDefend" /v "Start" /t REG_DWORD /d "4" /f
|
||||
|
||||
echo.
|
||||
echo Disable Security system tray icon
|
||||
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Systray" /v "HideSystray" /t REG_DWORD /d "1" /f
|
||||
|
||||
echo.
|
||||
echo Finishing up...
|
||||
reg add HKLM\SYSTEM\Setup /v DisabledDefenderServices /t REG_DWORD /d 1 /f
|
||||
|
||||
echo.
|
||||
echo Windows Defender has (hopefully) been disabled.
|
||||
echo You should still be able to scan files going forward. Also, the Antimalware Service Executable should immediately stop using CPU cycles.
|
||||
echo Please restart your computer to see all changes.
|
||||
|
||||
goto eof
|
||||
|
||||
:already_patched
|
||||
echo Defender has already been disabled by this script.
|
||||
|
||||
:eof
|
||||
echo.
|
||||
pause
|
||||
108
dotfiles/bin/antimalware-service-enable.bat
Normal file
108
dotfiles/bin/antimalware-service-enable.bat
Normal file
@@ -0,0 +1,108 @@
|
||||
@setlocal enableextensions enabledelayedexpansion
|
||||
@echo off
|
||||
|
||||
rem Make sure we're running as admin. Got this garbage from https://stackoverflow.com/a/40388766
|
||||
if not "%1"=="am_admin" (
|
||||
powershell -Command "Start-Process -Verb RunAs -FilePath '%0' -ArgumentList 'am_admin'"
|
||||
exit /b
|
||||
)
|
||||
|
||||
rem USE AT OWN RISK AS IS WITHOUT WARRANTY OF ANY KIND !!!!!
|
||||
rem
|
||||
rem Modified version of
|
||||
rem https://raw.githubusercontent.com/mattreecebentley/win10_disable_defender/main/win10_enable_defender.bat
|
||||
rem https://gist.github.com/xezrunner/a7a42dbc1096a40b0c78f09488fe5a2b
|
||||
rem
|
||||
rem Resources:
|
||||
rem https://docs.microsoft.com/en-us/powershell/module/defender/set-mppreference?view=win10-ps
|
||||
rem https://docs.microsoft.com/en-us/windows/threat-protection/windows-defender-exploit-guard/customize-exploit-protection
|
||||
rem https://github.com/AndyFul/ConfigureDefender
|
||||
rem https://github.com/AndyFul/Hard_Configurator
|
||||
|
||||
echo.
|
||||
echo Enabling Windows Defender
|
||||
reg query HKLM\SYSTEM\Setup /v DisabledDefenderServices | find "0x0"
|
||||
if %errorlevel% == 0 goto already_patched
|
||||
|
||||
reg delete "HKLM\Software\Policies\Microsoft\Windows Defender" /f
|
||||
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /v "SecurityHealth" /t REG_EXPAND_SZ /d "\"%windir%\system32\SecurityHealthSystray.exe\"" /f
|
||||
|
||||
echo.
|
||||
echo Restore WD shell
|
||||
reg add "HKLM\Software\Classes\*\shellex\ContextMenuHandlers\EPP" /ve /t REG_SZ /d "{09A47860-11B0-4DA5-AFA5-26D86198A780}" /f
|
||||
reg add "HKLM\Software\Classes\Drive\shellex\ContextMenuHandlers\EPP" /ve /t REG_SZ /d "{09A47860-11B0-4DA5-AFA5-26D86198A780}" /f
|
||||
reg add "HKLM\Software\Classes\Directory\shellex\ContextMenuHandlers\EPP" /ve /t REG_SZ /d "{09A47860-11B0-4DA5-AFA5-26D86198A780}" /f
|
||||
|
||||
echo.
|
||||
echo Enable WD services
|
||||
reg add "HKLM\System\CurrentControlSet\Services\BFE" /v "Start" /t REG_DWORD /d "2" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\MpsSvc" /v "Start" /t REG_DWORD /d "2" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\SecurityHealthService" /v "Start" /t REG_DWORD /d "2" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\SgrmBroker" /v "Start" /t REG_DWORD /d "2" /f
|
||||
|
||||
reg add "HKLM\System\CurrentControlSet\Services\wscsvc" /v "Start" /t REG_DWORD /d "2" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\WdBoot" /v "Start" /t REG_DWORD /d "2" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\wdFilter" /v "Start" /t REG_DWORD /d "2" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\WdNisDrv" /v "Start" /t REG_DWORD /d "2" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\WdNisSvc" /v "Start" /t REG_DWORD /d "2" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\WinDefend" /v "Start" /t REG_DWORD /d "2" /f
|
||||
|
||||
echo.
|
||||
echo 1 - Enable Logging
|
||||
reg add "HKLM\System\CurrentControlSet\Control\WMI\Autologger\DefenderApiLogger" /v "Start" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Control\WMI\Autologger\DefenderAuditLogger" /v "Start" /t REG_DWORD /d "1" /f
|
||||
|
||||
echo.
|
||||
echo Enable WD Tasks
|
||||
schtasks /Change /TN "Microsoft\Windows\ExploitGuard\ExploitGuard MDM policy Refresh" /Enable
|
||||
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Cache Maintenance" /Enable
|
||||
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Cleanup" /Enable
|
||||
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Scheduled Scan" /Enable
|
||||
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Verification" /Enable
|
||||
|
||||
echo.
|
||||
echo Setting various preferences
|
||||
rem CloudExtendedTimeout / 1 - 50 / block a suspicious file for up to 60 seconds (Default is 10)
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\MpEngine" /v "MpBafsExtendedTimeout" /t REG_DWORD /d "0" /f
|
||||
|
||||
rem CloudBlockLevel / 0 - Default / 2 - High / 4 - High+ / 6 - Zero tolerance (block all unknown executables)
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\MpEngine" /v "MpCloudBlockLevel" /t REG_DWORD /d "0" /f
|
||||
|
||||
rem 1 - Potentially Unwanted Application protection (PUP) is enabled, the applications with unwanted behavior will be blocked at download and install-time
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\MpEngine" /v "MpEnablePus" /t REG_DWORD /d "1" /f
|
||||
|
||||
rem Block at First Sight / 0 - Enable / 1 - Disable
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\SpyNet" /v "DisableBlockAtFirstSeen" /t REG_DWORD /d "0" /f
|
||||
|
||||
rem Cloud-based Protection / 0 - Disable / 1 - Basic / 2 - Advanced
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\SpyNet" /v "SpynetReporting" /t REG_DWORD /d "1" /f
|
||||
|
||||
rem Send file samples when further analysis is required / 0 - Always prompt / 1 - Send safe samples automatically / 2 - Never send / 3 - Send all samples automatically
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\SpyNet" /v "SubmitSamplesConsent" /t REG_DWORD /d "0" /f
|
||||
|
||||
echo.
|
||||
echo Attempting to enable Tamper Protection. If this fails then you need to do it manually.
|
||||
reg add "HKLM\Software\Microsoft\Windows Defender\Features" /v "TamperProtection" /t REG_DWORD /d "1" /f
|
||||
|
||||
rem To prevent WD using too much CPU, add this file to the exclusion list:
|
||||
rem C:\Program Files\Windows Defender\MsMpEng.exe
|
||||
echo.
|
||||
echo Attempting to exclude MsMpEng.exe to reduce CPU usage
|
||||
reg add "HKLM\Software\Microsoft\Windows Defender\Exclusions\Paths" /v "C:\Program Files\Windows Defender\MsMpEng.exe" /t REG_DWORD /d "0" /f
|
||||
|
||||
echo.
|
||||
echo Finishing up...
|
||||
reg add HKLM\SYSTEM\Setup /v DisabledDefenderServices /t REG_DWORD /d 0 /f
|
||||
|
||||
echo Windows Defender has (hopefully) been enabled.
|
||||
echo The Antimalware Service Executable should be active again.
|
||||
echo Restart your computer to see all changes.
|
||||
|
||||
goto eof
|
||||
|
||||
:already_patched
|
||||
echo Defender has already been enabled by this script.
|
||||
|
||||
:eof
|
||||
echo.
|
||||
pause
|
||||
@@ -42,6 +42,7 @@ if [[ ! -d "$repo_path" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
output_path="$output_path/svn"
|
||||
mkdir -p "$output_path"
|
||||
|
||||
now=$(echo $(date '+%Y-%m-%d-%H-%M-%S'))
|
||||
@@ -23,20 +23,25 @@ else
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
use_gpu=$1
|
||||
filename=$(basename -- "$2")
|
||||
output_name="$3"
|
||||
use_gpu=0
|
||||
|
||||
if [[ $use_gpu == "" || $2 == "" || $output_name == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <use-gpu (1|0)> <filename> <output name>${NORMAL}\n"
|
||||
if [[ $# < 2 || $# > 3 ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> ${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Found the following to work best with vids containing text (e.g. programming vid): 25 for CPU encoding and 27 for GPU.
|
||||
use_crf=25
|
||||
if [[ $use_gpu -eq 1 ]]; then
|
||||
use_crf=27
|
||||
filename=$(basename -- "$1")
|
||||
output_name="$2"
|
||||
|
||||
if [[ $# > 2 ]]; then
|
||||
use_gpu=$3
|
||||
fi
|
||||
|
||||
compress-video-with-crf $use_gpu $use_crf "$filename" "$output_name"
|
||||
# Found the following to work best with vids containing text (e.g. programming vid): 25 for CPU encoding and 27 for GPU.
|
||||
use_crf=21
|
||||
if [[ $use_gpu -eq 1 ]]; then
|
||||
use_crf=25
|
||||
fi
|
||||
|
||||
compress-video-with-crf $use_crf "$filename" "$output_name" $use_gpu
|
||||
|
||||
@@ -23,22 +23,36 @@ else
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
use_gpu=$1
|
||||
use_crf=$2
|
||||
output_name="$4"
|
||||
start_time="$5"
|
||||
end_time="$6"
|
||||
use_gpu=0
|
||||
|
||||
if [[ $use_gpu == "" || $use_crf == "" || $3 == "" || $output_name == "" || ($start_time != "" && $end_time == "") ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <use-gpu (1|0)> <crf value> <filename> <output name> <optional start time HH:MM:SS> <optional end time HH:MM:SS>\n\nIf you want to encode a range of CRF values then use -1 as the crf value.${NORMAL}\n"
|
||||
if [[ "$#" < 3 || "$#" > 6 ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <crf value> <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> <optional: start time HH:MM:SS> <optional: end time HH:MM:SS>\n\nIf you want to encode a range of CRF values then use -1 as the crf value.${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
use_crf=$1
|
||||
|
||||
filename=$(basename -- "$3")
|
||||
filename=$(basename -- "$2")
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
|
||||
output_name="$3"
|
||||
|
||||
if [[ "$#" > 3 ]]; then
|
||||
use_gpu=$4
|
||||
if [[ "$#" > 4 ]]; then
|
||||
start_time="$5"
|
||||
if [[ "$#" > 5 ]]; then
|
||||
end_time="$6"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $use_gpu -ne 0 && $use_gpu -ne 1 ]]; then
|
||||
printf "${BOLD}${RED}Invalid use_gpu value. Got $use_gpu, but expected either 0 or 1${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function encode() {
|
||||
crf=$1
|
||||
output="${output_name}.$extension"
|
||||
@@ -52,9 +66,14 @@ function encode() {
|
||||
|
||||
if [[ $use_gpu -eq 1 ]]; then
|
||||
# File will be slightly larger than CPU encoding, but it's much faster to transcode and doesn't max out the CPU cores.
|
||||
|
||||
# RTX 3080
|
||||
ffmpeg -y -stats -loglevel level+error $timing_args -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -i "$filename.$extension" -c:a copy -c:v h264_nvenc -profile:v high -rc:v vbr_hq -cq:v $crf -b:v 5M -maxrate 5M -max_muxing_queue_size 9999 "$output"
|
||||
|
||||
# GTX 1070
|
||||
#ffmpeg -y -stats -loglevel level+error $timing_args -vsync 0 -hwaccel cuvid -c:v h264_cuvid -i "$filename.$extension" -c:a copy -c:v h264_nvenc -profile:v high -rc:v vbr_hq -cq:v $crf -b:v 5M -maxrate 5M -max_muxing_queue_size 9999 "$output"
|
||||
else
|
||||
ffmpeg $timing_args -i "$filename.$extension" -c:v libx264 -crf $crf -preset veryfast -profile:v baseline -level 3.0 -strict -2 "$output"
|
||||
ffmpeg -y -stats -loglevel level+error $timing_args -i "$filename.$extension" -c:v libx264 -crf $crf -preset veryfast -profile:v high -level 3.0 -strict -2 "$output"
|
||||
fi
|
||||
printf "\n${GREEN}${BOLD}Finished encoding '$filename.$extension' (CRF $crf) | output name '$output'${NORMAL}\n\n"
|
||||
}
|
||||
@@ -29,7 +29,7 @@ else
|
||||
fi
|
||||
|
||||
if [[ $1 == "" || $2 == "" ]]; then
|
||||
printf "${BOLD}${RED}Format: $0 <filename> <bitrate, e.g. \"4000k\"> <optional output name>${NORMAL}\n"
|
||||
printf "${BOLD}${RED}Usage: $0 <filename> <bitrate, e.g. \"4000k\"> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -27,7 +27,7 @@ else
|
||||
fi
|
||||
|
||||
if [[ $1 == "" || $2 == "" ]]; then
|
||||
printf "${BOLD}${RED}Format: $0 <compress 1|0> <filename> <optional output name>${NORMAL}\n"
|
||||
printf "${BOLD}${RED}Usage: $0 <compress 1|0> <filename> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
64
dotfiles/bin/convert-video-mkv-to-mp4
Normal file
64
dotfiles/bin/convert-video-mkv-to-mp4
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This is for reencoding an mkv video to mp4 using an mpeg4 encoder.
|
||||
# Can optionally compress the video.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $1 == "" || $2 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <compress 1|0> <filename> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
compress="$1"
|
||||
|
||||
filename=$(basename -- "$2")
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
|
||||
output="$3"
|
||||
if [[ $output == "" ]]; then
|
||||
output="${filename}_CONVERTED"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Encoding '$filename.$extension' | compress: $compress | output: $output.mp4${NORMAL}\n"
|
||||
|
||||
if [[ $compress -eq 1 ]]; then
|
||||
temp_output="temp_$output.mp4"
|
||||
else
|
||||
temp_output="$output.mp4"
|
||||
fi
|
||||
|
||||
# convert first.
|
||||
# we convert then compress instead of compressing on first pass because this results in a slightly higher bitrate.
|
||||
ffmpeg -y -stats -loglevel level+error -i "$filename.$extension" -vcodec copy -acodec copy "$temp_output"
|
||||
|
||||
if [[ $compress -eq 1 ]]; then
|
||||
compress-video 1 "$temp_output" "$output"
|
||||
rm "$temp_output"
|
||||
else
|
||||
printf "\n"
|
||||
fi
|
||||
|
||||
printf "${GREEN}${BOLD}Done encoding '$filename.$extension' to '$output.mp4'${NORMAL}\n\n"
|
||||
50
dotfiles/bin/extract-16bit-wav-from-video
Normal file
50
dotfiles/bin/extract-16bit-wav-from-video
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
input="$1"
|
||||
output_name="$2"
|
||||
|
||||
if [[ $input == "" || $output_name == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <input video> <wav output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$input" ]]; then
|
||||
printf "${RED}${BOLD}Error: failed to extract audio. Video file \"$input\" doesn't exist.\n${NORMAL}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Add extension if not provided.
|
||||
output_basename=$(basename -- "$output_name")
|
||||
output_extension="${output_basename##*.}"
|
||||
if [[ $output_extension != "wav" ]]; then
|
||||
output_name="${output_name}.wav"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Extracting 16-bit WAV from $input | output: $output_name${NORMAL}\n"
|
||||
|
||||
ffmpeg -i "$input" -ar 16000 -ac 1 -c:a pcm_s16le "$output_name"
|
||||
|
||||
printf "${GREEN}${BOLD}Done extracting 16-bit WAV from $input | output: $output_name${NORMAL}\n"
|
||||
@@ -41,7 +41,7 @@ if [[ $bitrate == "" ]]; then
|
||||
bitrate="64"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Extracting audio from '$filename.$extension' | bitrate: ${bitrate}k | output: $output_name${NORMAL}\n"
|
||||
printf "\n${YELLOW}${BOLD}Extracting audio from $filename.$extension | bitrate: ${bitrate}k | output: $output_name${NORMAL}\n"
|
||||
|
||||
if [[ $transcode == "1" ]]; then
|
||||
# Transcode audio
|
||||
@@ -51,5 +51,5 @@ else
|
||||
ffmpeg -i "$filename.$extension" -vn -acodec copy "$output_name"
|
||||
fi
|
||||
|
||||
printf "\n${GREEN}${BOLD}Done extracting audio from '$filename.$extension' | output name '$output_name'${NORMAL}\n\n"
|
||||
printf "\n${GREEN}${BOLD}Done extracting audio from $filename.$extension | output name '$output_name'${NORMAL}\n\n"
|
||||
|
||||
21
dotfiles/bin/file-portex-analyzer.bat
Normal file
21
dotfiles/bin/file-portex-analyzer.bat
Normal file
@@ -0,0 +1,21 @@
|
||||
@echo off
|
||||
|
||||
if exist %1\* (
|
||||
echo directory
|
||||
for /F "delims=" %%f in ('dir /b /s %1') do (
|
||||
:: skip folders
|
||||
if not exist "%%~f\" (
|
||||
java -jar %DEV_TOOLS%\PortexAnalyzer.jar -p "%%~f_PortexAnalyzer_Report.png" -o "%%~f_PortexAnalyzer_Report.txt" "%%~f" | more
|
||||
)
|
||||
)
|
||||
) else (
|
||||
if exist "%~1_PortexAnalyzer_Report.txt" (
|
||||
del "%~1_PortexAnalyzer_Report.txt"
|
||||
)
|
||||
if exist "%~1_PortexAnalyzer_Report.png" (
|
||||
del "%~1_PortexAnalyzer_Report.png"
|
||||
)
|
||||
java -jar %DEV_TOOLS%\PortexAnalyzer.jar -p "%~1_PortexAnalyzer_Report.png" -o "%~1_PortexAnalyzer_Report.txt" "%~1" | more
|
||||
start notepad "%~1_PortexAnalyzer_Report.txt"
|
||||
start rundll32 "C:\Program Files (x86)\Windows Photo Viewer\PhotoViewer.dll", ImageView_Fullscreen %~1_PortexAnalyzer_Report.png
|
||||
)
|
||||
3
dotfiles/bin/file-resource-hacker.bat
Normal file
3
dotfiles/bin/file-resource-hacker.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
|
||||
start %DEV_TOOLS%\ResourceHacker.exe "%~1"
|
||||
12
dotfiles/bin/file-sigcheck.bat
Normal file
12
dotfiles/bin/file-sigcheck.bat
Normal file
@@ -0,0 +1,12 @@
|
||||
@echo off
|
||||
|
||||
cd %DEV_TOOLS%\SysinternalsSuite
|
||||
if exist %1\* (
|
||||
echo Run on a file
|
||||
) else (
|
||||
if exist "%~1_Report.txt" (
|
||||
del "%~1_Report.txt"
|
||||
)
|
||||
sigcheck.exe /a "%~1" > "%~1_sigcheck_report.txt"
|
||||
start notepad "%~1_sigcheck_report.txt"
|
||||
)
|
||||
3
dotfiles/bin/file-x32dbg.bat
Normal file
3
dotfiles/bin/file-x32dbg.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
|
||||
start %DEV_TOOLS%\x64dbg\release\x32\x32dbg.exe "%~1"
|
||||
3
dotfiles/bin/file-x64dbg.bat
Normal file
3
dotfiles/bin/file-x64dbg.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
|
||||
start %DEV_TOOLS%\x64dbg\release\x64\x64dbg.exe "%~1"
|
||||
@@ -27,7 +27,7 @@ else
|
||||
fi
|
||||
|
||||
if [[ $1 == "" ]]; then
|
||||
printf "\n${BOLD}Usage: $0 <filename> <optional output name>${NORMAL}\n"
|
||||
printf "${BOLD}${RED}Usage: $0 <filename> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -29,7 +29,7 @@ else
|
||||
fi
|
||||
|
||||
if [[ $1 == "" ]]; then
|
||||
printf "\n${BOLD}Usage: $0 <filename> <optional output name>${NORMAL}\n"
|
||||
printf "${BOLD}${RED}Usage: $0 <filename> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
49
dotfiles/bin/remove-audio-from-video
Normal file
49
dotfiles/bin/remove-audio-from-video
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $1 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <filename> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
|
||||
output_name="$2"
|
||||
|
||||
if [[ $output_name == "" ]]; then
|
||||
output="${filename}_no_audio.$extension"
|
||||
else
|
||||
output="${output_name}.$extension"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Removing audio from '$filename.$extension' | output: '$output'${NORMAL}\n"
|
||||
|
||||
# -an removes the audio.
|
||||
ffmpeg -i "$filename.$extension" -c:v copy -an "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Done removing audio from '$filename.$extension' | output: '$output'${NORMAL}\n\n"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source "$HOME/.dotfiles/script_helpers/all.sh"
|
||||
source "$HOME/dotfiles/script_helpers/all.sh"
|
||||
|
||||
cwd=$PWD
|
||||
source_path=""
|
||||
94
dotfiles/bin/transcribe-audio
Normal file
94
dotfiles/bin/transcribe-audio
Normal file
@@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# The base model is pretty good overall. It has good punctuation inserting and catches most words.
|
||||
# Tiny is fast and often has correct grammar, but it misses a lot of words, especially when the
|
||||
# source isn't loud or is muffled.
|
||||
#
|
||||
# Small and medium models can do better word detection at times, but suffer from a lack of punctuation.
|
||||
# Medium is particularly bad and often excludes periods and commas.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
# Will return a symlink path in its expanded form. If the path's root is the
|
||||
# home directory symbol "~" then it'll be replaced by the full home path.
|
||||
expand_path() {
|
||||
local ret="$1"
|
||||
|
||||
IFS="/" read -ra parts <<< "$ret"
|
||||
if [[ "${parts[0]}" == "~" ]]; then
|
||||
ret="$HOME"
|
||||
for ((i=1; i < ${#parts[@]}; i++))
|
||||
do
|
||||
ret="$ret/${parts[$i]}"
|
||||
done
|
||||
fi
|
||||
ret=$(readlink -m "$ret")
|
||||
echo $ret
|
||||
}
|
||||
|
||||
input_wav="$1"
|
||||
output_name_without_ext="$2"
|
||||
model="$3"
|
||||
threads=$4
|
||||
|
||||
# 4 seems to be the sweet spot for most models, except medium might be faster with 8.
|
||||
default_thread_count=4
|
||||
|
||||
if [[ $input_wav == "" || $output_name_without_ext == "" || $model == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <input.wav> <output name without extension> <model name> <optional: thread count>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$input_wav" ]]; then
|
||||
printf "${RED}${BOLD}Input file \"$input_wav\" doesn't exist!\n${NORMAL}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $threads == "" ]]; then
|
||||
threads=$default_thread_count
|
||||
fi
|
||||
|
||||
output_name="$output_name_without_ext.${model}"
|
||||
|
||||
|
||||
# 1 core 31 threads has very fast pcm_to_mel conversion and then just one core doing most of the work. You get more accurate results this way.
|
||||
# 2 core 16 is about half the time but it can have errors where the two pieces come together. This only gets more likely as the core count is increased.
|
||||
# 8 threads, 4 cores is good too for tiny,small and 2 threads, 4 cores for medium.
|
||||
|
||||
threads=31 #keep a thread for me
|
||||
cores=1
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Transcribing $input_wav | model: $model | cores: $cores | threads: $threads | output: $output_name ${NORMAL}\n"
|
||||
|
||||
whisper_fullname="$(expand_path $(which whisper.exe))"
|
||||
whisper_path="$(dirname $whisper_fullname)"
|
||||
models_path="$whisper_path/models"
|
||||
|
||||
whisper.exe --processors ${cores} --threads ${threads} -m "$models_path/ggml-${model}.en.bin" -otxt -osrt -f "$input_wav" -of "$output_name" --print-colors --print-progress
|
||||
error=$?
|
||||
if [[ error -eq 0 ]]; then
|
||||
printf "${GREEN}${BOLD}Done transcribing $input_wav | model: $model | cores: $cores | threads: $threads | output: $output_name${NORMAL}\n"
|
||||
else
|
||||
printf "${GREEN}${BOLD}Error while transcribing $input_wav | model: $model | cores: $cores | threads: $threads | output: $output_name${NORMAL}\n"
|
||||
fi
|
||||
65
dotfiles/bin/transcribe-video
Normal file
65
dotfiles/bin/transcribe-video
Normal file
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
input_video="$1"
|
||||
output_name_without_ext="$2"
|
||||
shift 2
|
||||
models=("$@")
|
||||
|
||||
if [[ $input_video == "" || $output_name_without_ext == "" || ${#models[@]} -eq 0 ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <input.mp4> <output name without extension> <list of model names to use>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
model_csv=$(IFS=_ ; echo "${models[*]}")
|
||||
wav_name="${output_name_without_ext}_${model_csv}_${RANDOM}"
|
||||
|
||||
# Add extension if not provided.
|
||||
input_basename=$(basename -- "$wav_name")
|
||||
input_extension="${input_basename##*.}"
|
||||
if [[ input_extension != "wav" ]]; then
|
||||
wav_name="${wav_name}.wav"
|
||||
fi
|
||||
|
||||
extract-16bit-wav-from-video "$input_video" "$wav_name"
|
||||
if [[ $? == 1 ]]; then exit 1; fi
|
||||
|
||||
for model in "$@"; do
|
||||
# Tweak thread count based on model size.
|
||||
thread_count=4
|
||||
if [[ $model == "medium" ]]; then
|
||||
thread_count=8
|
||||
fi
|
||||
|
||||
transcribe-audio "$wav_name" "$output_name_without_ext" "${model}" $thread_count
|
||||
|
||||
if [[ $? == 1 ]]; then
|
||||
printf "${RED}${BOLD}Saving the audio file \"$wav_name\" in case you want to reuse it for debugging.\n${NORMAL}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
rm "$wav_name"
|
||||
|
||||
2
dotfiles/bin/transcribe-video-base
Normal file
2
dotfiles/bin/transcribe-video-base
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
transcribe-video "$1" "$2" "base"
|
||||
2
dotfiles/bin/transcribe-video-medium
Normal file
2
dotfiles/bin/transcribe-video-medium
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
transcribe-video "$1" "$2" "medium"
|
||||
2
dotfiles/bin/transcribe-video-small
Normal file
2
dotfiles/bin/transcribe-video-small
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
transcribe-video "$1" "$2" "small"
|
||||
2
dotfiles/bin/transcribe-video-tiny
Normal file
2
dotfiles/bin/transcribe-video-tiny
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
transcribe-video "$1" "$2" "tiny"
|
||||
48
dotfiles/bin/trim-accurate-video
Normal file
48
dotfiles/bin/trim-accurate-video
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Reencodes the video with a more accurate length.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
output_name="$2"
|
||||
start_time="$3"
|
||||
end_time="$4"
|
||||
|
||||
if [[ $filename == "" || $output_name == "" || $start_time == "" || $end_time == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <filename> <output name> <start time HH:MM:SS> <end time HH:MM:SS>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
output="${output_name}.$extension"
|
||||
timing_args="-ss $start_time -to $end_time"
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Trimming '$filename.$extension' | output: $output | start: $start_time | end: $end_time${NORMAL}\n"
|
||||
|
||||
ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -i "$filename.$extension" -c:v libx264 -c:a copy "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
|
||||
|
||||
@@ -40,7 +40,7 @@ timing_args="-ss $start_time -to $end_time"
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Trimming '$filename.$extension' | output: $output | start: $start_time | end: $end_time${NORMAL}\n"
|
||||
|
||||
ffmpeg -y -stats -loglevel level+error $timing_args -i "$filename.$extension" -c:a copy -c:v copy "$output"
|
||||
ffmpeg -y -stats -loglevel level+error $timing_args -i "$filename.$extension" -c copy "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
# If you're getting signature errors, check out https://www.msys2.org/news/#2020-06-29-new-packagers and/or other news posts.
|
||||
|
||||
source "$HOME/.dotfiles/script_helpers/printing.sh"
|
||||
source "$HOME/.dotfiles/script_helpers/platform.sh"
|
||||
source "$HOME/dotfiles/script_helpers/printing.sh"
|
||||
source "$HOME/dotfiles/script_helpers/platform.sh"
|
||||
|
||||
set -e
|
||||
|
||||
89
install → dotfiles/install
Executable file → Normal file
89
install → dotfiles/install
Executable file → Normal file
@@ -4,7 +4,7 @@ if [[ $(uname) == 'Darwin' ]]; then
|
||||
if ! command -v brew &>/dev/null
|
||||
then
|
||||
# We need to update bash, so we'll start with setting up homebrew.
|
||||
./osx/pre_install
|
||||
./macos/pre_install
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
@@ -52,31 +52,6 @@ setup_zsh() {
|
||||
if [[ $is_linux -eq 1 ]]; then
|
||||
sudo apt install zsh
|
||||
fi
|
||||
|
||||
make_link .dotfiles/zsh/core .zsh
|
||||
|
||||
FILES=()
|
||||
FILES+=('zshrc')
|
||||
FILES+=('zlogin')
|
||||
|
||||
for file in "${FILES[@]}"
|
||||
do
|
||||
make_link .dotfiles/zsh/$file .$file
|
||||
done
|
||||
}
|
||||
|
||||
setup_bash() {
|
||||
printf "${MAGENTA}==> ${NORMAL}Setting up bash...\n"
|
||||
|
||||
FILES=()
|
||||
FILES+=('bashrc')
|
||||
FILES+=('bash_profile')
|
||||
FILES+=('inputrc')
|
||||
|
||||
for file in "${FILES[@]}"
|
||||
do
|
||||
make_link .dotfiles/bash/$file .$file
|
||||
done
|
||||
}
|
||||
|
||||
####################################################################################################
|
||||
@@ -85,40 +60,6 @@ setup_bash() {
|
||||
|
||||
pushd "$HOME" &>/dev/null
|
||||
|
||||
make_link $dotfiles_dir .dotfiles 1 # expand source path in case we're reinstalling and the cwd is a symlink.
|
||||
|
||||
if [[ $is_windows -eq 1 ]]; then
|
||||
do_vim_copy=1
|
||||
if [[ -d "$PWD/.vim" ]]; then
|
||||
printf "\n${BOLD}Vim folder already found at destination. Overwrite? [1,0]\n> ${NORMAL}"
|
||||
read -e copy_vim
|
||||
if [[ $copy_vim != "0" && $copy_vim != "1" ]]; then
|
||||
fatal "Invalid value '$copy_vim'"
|
||||
elif [[ $copy_vim == "0" ]]; then
|
||||
do_vim_copy=0
|
||||
printf "\n"
|
||||
fi
|
||||
fi
|
||||
if [[ $do_vim_copy -eq 1 ]]; then
|
||||
printf "${MAGENTA}==> ${NORMAL}Copying ${YELLOW}.dotfiles/vim${NORMAL} to ${YELLOW}$PWD/.vim${NORMAL}\n"
|
||||
cp -r .dotfiles/vim .vim
|
||||
fi
|
||||
else
|
||||
make_link .dotfiles/vim .vim
|
||||
fi
|
||||
|
||||
FILES=()
|
||||
FILES+=('env.loader')
|
||||
FILES+=('aliases')
|
||||
FILES+=('gitconfig')
|
||||
FILES+=('vimrc')
|
||||
FILES+=('curlrc')
|
||||
|
||||
for file in "${FILES[@]}"
|
||||
do
|
||||
make_link .dotfiles/$file .$file
|
||||
done
|
||||
|
||||
set +e
|
||||
git_comp_filename=".git-completion.bash"
|
||||
printf "${MAGENTA}==> ${NORMAL}Downloading Git completion list to ${YELLOW}$PWD/$git_comp_filename${NORMAL}\n"
|
||||
@@ -129,37 +70,19 @@ set -e
|
||||
# Setup platform files
|
||||
#########################
|
||||
|
||||
if [[ $is_windows -eq 1 ]]; then
|
||||
printf "\n${BOLD}Setting up Windows${NORMAL}\n\n"
|
||||
os_name="windows"
|
||||
# Already using bash if running msys2.
|
||||
setup_bash
|
||||
elif [[ $is_macos -eq 1 ]]; then
|
||||
if [[ $is_macos -eq 1 ]]; then
|
||||
printf "\n${BOLD}Setting up MacOS${NORMAL}\n\n"
|
||||
os_name="osx"
|
||||
$dotfiles_dir/macos/install
|
||||
# might just switch back to bash since the zsh stuff is ancient.
|
||||
setup_zsh
|
||||
setup_bash
|
||||
use_shell zsh
|
||||
|
||||
elif [[ $is_linux -eq 1 ]]; then
|
||||
printf "\n${BOLD}Setting up Linux${NORMAL}\n\n"
|
||||
os_name="linux"
|
||||
setup_zsh
|
||||
setup_bash
|
||||
$dotfiles_dir/linux/install
|
||||
use_shell bash
|
||||
fi
|
||||
|
||||
if [[ $os_name != "" ]]; then
|
||||
if [ -f .dotfiles/$os_name/env.platform ]; then
|
||||
make_link .dotfiles/$os_name/env.platform .env.platform
|
||||
fi
|
||||
|
||||
if [ -f .dotfiles/$os_name/gitconfig.platform ]; then
|
||||
make_link .dotfiles/$os_name/gitconfig.platform .gitconfig.platform
|
||||
fi
|
||||
|
||||
$dotfiles_dir/$os_name/install
|
||||
fi
|
||||
|
||||
popd "$HOME" &>/dev/null
|
||||
|
||||
printf "${BOLD}${GREEN}Done!${NORMAL}\n"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user