dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit b1eef4e2a66a18729049eac1c53eede87baaf26b
parent bc1401cbad9f4b2780e519a4a652f13fbf566b33
Author: Alex Balgavy <a.balgavy@gmail.com>
Date:   Mon, 29 Jul 2019 23:21:50 +0200

set editor based on osascript

In commonprofile, set THEME to DARK/LIGHT based on osascript's response.
Vim then checks the value of THEME and sets colorscheme accordingly.


Former-commit-id: 9dedf2a6cfc8e4d4281d6719fa323a0dc64c1527
Diffstat:
Mshell/commonprofile | 23+++++++++++++----------
Mvim/vimrc | 39+++++++++++++++++++++++----------------
2 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/shell/commonprofile b/shell/commonprofile @@ -8,12 +8,19 @@ export \ PATH GOPATH \ - DOTFILES MUSIC_DIR \ + DOTFILES MUSIC_DIR THEME \ EDITOR HOMEBREW_EDITOR \ VIRTUALENVWRAPPER_PYTHON PIP_REQUIRE_VIRTUALENV WORKON_HOME VIRTUALENVWRAPPER_SCRIPT\ CASK_REPO \ SHELLCHECK_OPTS +# Set the general theme +if [ $(osascript -e 'tell app "System Events" to tell appearance preferences to get dark mode') = 'true' ]; then + THEME="DARK" +else + THEME="LIGHT" +fi + # Add API keys and stuff if [ -f "$HOME/.secret_env_variables" ]; then source "$HOME/.secret_env_variables" @@ -50,10 +57,11 @@ DOTFILES="$HOME/.dotfiles" # Where my music is located MUSIC_DIR="$HOME/Music/iTunes/iTunes Media/Music" +# My editor EDITOR="vim" if command -v brew &> /dev/null; then - HOMEBREW_EDITOR="vim" + HOMEBREW_EDITOR="$EDITOR" CASK_REPO=$(brew --repository)/Library/Taps/homebrew/homebrew-cask fi @@ -109,11 +117,6 @@ alias df="df -h" # Preferred 'df' alias htop='sudo htop' # Top should launch htop with sudo alias g='git' # Make git easier to type alias r='source ranger' # Make Ranger easier to type and keep directory -if [ $(osascript -e 'tell app "System Events" to tell appearance preferences to get dark mode') = 'true' ]; then - alias vim='vim -c "Dark"' -else - alias vim='vim -c "Light"' -fi alias wheredef='type -a' # Where is a function defined? alias lsblk="lsblk -o NAME,LABEL,PARTLABEL,TYPE,FSTYPE,SIZE,MOUNTPOINT,STATE" alias rmcolors="sed \"s,\x1B\[[0-9;]*[a-zA-Z],,g\"" # Remove ANSI color codes from text @@ -172,7 +175,7 @@ notify() { # Reload configs reload() { - START_TIME=$SECONDS + local START_TIME=$SECONDS source "$HOME"/.commonprofile if [[ $SHELL = *"zsh"* ]]; then @@ -270,7 +273,7 @@ realpath() { # Remove aliases & replace with original files unlink() { for i in "$@"; do - p=$(realpath -w "$i") + local p=$(realpath -w "$i") rm "$i" mv "$p" . unset p @@ -284,7 +287,7 @@ if command -v osascript &> /dev/null; then # cd to current Finder directory cdf() { - target=$(osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)') + local target=$(osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)') if [ "$target" != "" ]; then cd "$target" || return; pwd else diff --git a/vim/vimrc b/vim/vimrc @@ -209,9 +209,30 @@ let g:vimwiki_list = [wiki] let g:vimwiki_global_ext = 0 let g:vimwiki_ext2syntax = {'.wiki': 'default'} " }}} + +set omnifunc=syntaxcomplete#Complete " }}} " }}} " General {{{ +" Set the colors +" Use true color +if has('termguicolors') + set termguicolors +endif + +if has_key(environ(), 'THEME') + if environ()['THEME'] == 'DARK' + set background=dark + colorscheme junipero + else + set background=light + colorscheme kuroi + endif +else + set background=light + colorscheme kuroi +endif + " where to find tags files set tags=./tags,tags,.git/tags @@ -258,7 +279,7 @@ set fileformats=unix,dos,mac " Number of lines to use for command line " (this fixes the 'press enter to continue' thing on :help) -set cmdheight=2 +set cmdheight=1 " netrw {{{ let g:netrw_banner = 0 " hide the banner @@ -270,24 +291,12 @@ let g:netrw_list_hide = &wildignore " Send more characters at a given time set ttyfast -" Use true color -if has('termguicolors') - set termguicolors -endif - -" Colorscheme -colorscheme wal -set notermguicolors - " Show partial command on last line set showcmd " Command completion set wildmenu -" Use colors that work on a dark background -set background=dark - " Mouse tweak set mousemodel=popup @@ -413,14 +422,12 @@ set whichwrap+=<,>,h,l " Better completion set complete=.,w,b,u,t -set completeopt=longest,menuone,preview +set completeopt=menu,menuone,noinsert,noselect " Keep cursor off top and bottom of screen set scrolloff=5 " }}} " Commands {{{ -command! Light set background=light termguicolors | colorscheme kuroi -command! Dark set background=dark termguicolors | colorscheme junipero command! TodoP vimgrep /^ *[#%\/E]* *\(TODO\|TO DO\)/ **/*.* | copen command! Todo vimgrep /^ *[#%\/E]* *\(TODO\|TO DO\)/ % | copen command! NoteP vimgrep /NOTE\C/ **/*.* | copen