Improve OSX setup
This commit is contained in:
parent
ee11695dee
commit
e2f40a7be7
2
aliases
2
aliases
|
@ -39,7 +39,6 @@ abort() {
|
||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
if [[ $platform == 'Linux' || $platform == 'Darwin' ]]; then
|
if [[ $platform == 'Linux' || $platform == 'Darwin' ]]; then
|
||||||
#source ~/.zshrc
|
|
||||||
test -f ~/.aliases && . ~/.aliases
|
test -f ~/.aliases && . ~/.aliases
|
||||||
else
|
else
|
||||||
test -f ~/.aliases && . ~/.aliases
|
test -f ~/.aliases && . ~/.aliases
|
||||||
|
@ -445,6 +444,7 @@ alias pdot='cd ~/.private-dotfiles'
|
||||||
alias duh='du -csh'
|
alias duh='du -csh'
|
||||||
alias exp='explorer .'
|
alias exp='explorer .'
|
||||||
alias f='fg'
|
alias f='fg'
|
||||||
|
alias grep='grep -n --color '
|
||||||
alias history='fc -l 1'
|
alias history='fc -l 1'
|
||||||
alias histroy='history'
|
alias histroy='history'
|
||||||
alias irb='irb --readline -r irb/completion'
|
alias irb='irb --readline -r irb/completion'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if which tput >/dev/null 2>&1; then
|
if which tput >/dev/null 2>&1; then
|
||||||
ncolors=$(tput colors)
|
ncolors=$(tput colors)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
source "$HOME/.dotfiles/script_helpers/all.sh"
|
source "$HOME/.dotfiles/script_helpers/all.sh"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if which tput >/dev/null 2>&1; then
|
if which tput >/dev/null 2>&1; then
|
||||||
ncolors=$(tput colors)
|
ncolors=$(tput colors)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
source "$HOME/.dotfiles/script_helpers/printing.sh"
|
source "$HOME/.dotfiles/script_helpers/printing.sh"
|
||||||
source "$HOME/.dotfiles/script_helpers/platform.sh"
|
source "$HOME/.dotfiles/script_helpers/platform.sh"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Copies vim data from the home directory to the dotfiles repo.
|
# Copies vim data from the home directory to the dotfiles repo.
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Copies vim data from the dotfiles repo to the home directory.
|
# Copies vim data from the dotfiles repo to the home directory.
|
||||||
|
|
||||||
|
|
68
install
Normal file → Executable file
68
install
Normal file → Executable file
|
@ -1,4 +1,15 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
platform=`uname`
|
||||||
|
|
||||||
|
if [[ $platform == '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
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
source "script_helpers/printing.sh"
|
source "script_helpers/printing.sh"
|
||||||
source "script_helpers/core.sh"
|
source "script_helpers/core.sh"
|
||||||
|
@ -6,9 +17,10 @@ source "script_helpers/platform.sh"
|
||||||
source "script_helpers/file_ops.sh"
|
source "script_helpers/file_ops.sh"
|
||||||
|
|
||||||
cwd=$PWD
|
cwd=$PWD
|
||||||
platform=`uname`
|
|
||||||
confirm_link=0
|
confirm_link=0
|
||||||
os_is_windows is_windows
|
os_is_windows is_windows
|
||||||
|
os_is_macos is_macos
|
||||||
|
os_is_linux is_linux
|
||||||
|
|
||||||
if [[ $is_windows -eq 1 ]]; then
|
if [[ $is_windows -eq 1 ]]; then
|
||||||
# Check for admin permissions.
|
# Check for admin permissions.
|
||||||
|
@ -26,32 +38,34 @@ set -e
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
|
|
||||||
setup_zsh() {
|
setup_zsh() {
|
||||||
printf "Setting up zsh...\n"
|
printf "Setting up zsh...\n"
|
||||||
|
|
||||||
sudo apt install zsh
|
if [[ $is_linux -eq 1 ]]; then
|
||||||
|
sudo apt install zsh
|
||||||
TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
|
|
||||||
if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
|
|
||||||
if hash chsh >/dev/null 2>&1; then
|
|
||||||
printf "\n${BLUE}Changing the default shell to zsh${NORMAL}\n"
|
|
||||||
chsh -s $(grep /zsh$ /etc/shells | tail -1)
|
|
||||||
else
|
|
||||||
printf "\n${RED}Unable to change the shell because this system does not have chsh.\n"
|
|
||||||
printf "${BLUE}If this is Windows then you probably want to run the bash installer.${NORMAL}\n"
|
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
FILES=()
|
TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
|
||||||
FILES+=('zsh')
|
if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
|
||||||
FILES+=('zshrc')
|
if hash chsh >/dev/null 2>&1; then
|
||||||
FILES+=('zshenv')
|
printf "\n${BLUE}Changing the default shell to zsh${NORMAL}\n"
|
||||||
FILES+=('zlogin')
|
chsh -s $(grep /zsh$ /etc/shells | tail -1)
|
||||||
FILES+=('zprofile')
|
else
|
||||||
|
printf "\n${RED}Unable to change the shell because this system does not have chsh.\n"
|
||||||
|
printf "${BLUE}If this is Windows then you probably want to run the bash installer.${NORMAL}\n"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
for file in "${FILES[@]}"
|
setup_dir .dotfiles/zsh .zsh
|
||||||
do
|
|
||||||
setup_file "$file"
|
FILES=()
|
||||||
done
|
FILES+=('zshrc')
|
||||||
|
FILES+=('zshenv')
|
||||||
|
FILES+=('zlogin')
|
||||||
|
|
||||||
|
for file in "${FILES[@]}"
|
||||||
|
do
|
||||||
|
setup_file .dotfiles/$file .$file
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
|
@ -96,9 +110,9 @@ if [[ $is_windows -eq 0 ]]; then
|
||||||
setup_zsh
|
setup_zsh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $platform == 'Darwin' ]]; then
|
if [[ $is_macos -eq 1 ]]; then
|
||||||
printf "\n${BOLD}Running the OS X installer${NORMAL}\n"
|
printf "\n${BOLD}Running the MacOS installer${NORMAL}\n"
|
||||||
./osx/install.sh
|
$cwd/osx/install
|
||||||
fi
|
fi
|
||||||
|
|
||||||
popd "$HOME" &>/dev/null
|
popd "$HOME" &>/dev/null
|
||||||
|
|
75
osx/install
Executable file
75
osx/install
Executable file
|
@ -0,0 +1,75 @@
|
||||||
|
#!/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)"
|
||||||
|
BOLD="$(tput bold)"
|
||||||
|
NORMAL="$(tput sgr0)"
|
||||||
|
else
|
||||||
|
RED=""
|
||||||
|
GREEN=""
|
||||||
|
YELLOW=""
|
||||||
|
BLUE=""
|
||||||
|
BOLD=""
|
||||||
|
NORMAL=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
printf "Installing env...\n"
|
||||||
|
ln -sf $HOME/.dotfiles/osx/env.platform $HOME/.env.platform
|
||||||
|
|
||||||
|
printf "Installing Git customizations...\n"
|
||||||
|
ln -sf $HOME/.dotfiles/osx/gitconfig.platform $HOME/.gitconfig.platform
|
||||||
|
|
||||||
|
#-----------------------------------
|
||||||
|
# Homebrew packages
|
||||||
|
#-----------------------------------
|
||||||
|
|
||||||
|
printf "Installing Homebrew...\n"
|
||||||
|
|
||||||
|
brew_packages=(
|
||||||
|
'openssl'
|
||||||
|
'wget'
|
||||||
|
'git'
|
||||||
|
'rlwrap'
|
||||||
|
'cmake'
|
||||||
|
'vim'
|
||||||
|
'sdl'
|
||||||
|
'tree'
|
||||||
|
)
|
||||||
|
brew tap homebrew/core
|
||||||
|
for package in "${brew_packages[@]}"
|
||||||
|
do
|
||||||
|
printf "Installing $package...\n"
|
||||||
|
ret=$(brew list | awk /$package/)
|
||||||
|
if [[ $ret == $package ]]; then
|
||||||
|
printf "${YELLOW}Already installed!${NORMAL}\n"
|
||||||
|
else
|
||||||
|
eval "brew install $package"
|
||||||
|
printf \n
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# We have issues downloading Rust on 10.11 with the patched Homebrew checkout
|
||||||
|
# so we'll install it using their script.
|
||||||
|
bash -c "$(curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs)"
|
||||||
|
|
||||||
|
# For Vim search
|
||||||
|
cargo install ripgrep
|
||||||
|
|
||||||
|
# The homebrew core ctags package is very old.
|
||||||
|
brew install --HEAD universal-ctags/universal-ctags/universal-ctags
|
||||||
|
|
||||||
|
printf "\n${YELLOW}If you haven't already installed the Xcode dev tools then do so now by installing Xcode from the App Store:${NORMAL}\n"
|
||||||
|
printf "When that finishes open a terminal and run the following:\n"
|
||||||
|
printf " 1. ${YELLOW}sudo xcode-select --install${NORMAL}\n"
|
||||||
|
printf " 2. ${YELLOW}sudo xcodebuild -license${NORMAL}\n"
|
||||||
|
printf " 3. ${YELLOW}sudo xcode-select -s /Applications/Xcode.app/Contents/Developer${NORMAL}\n"
|
||||||
|
|
||||||
|
printf "\n${BOLD}Finished setting up OS X${NORMAL}\n"
|
|
@ -1,52 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
source "../script_helpers/printing.sh"
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
printf "Installing env...\n"
|
|
||||||
ln -sf $HOME/.dotfiles/osx/env.platform $HOME/.env.platform
|
|
||||||
|
|
||||||
printf "Installing git customizations...\n"
|
|
||||||
ln -sf $HOME/.dotfiles/osx/gitconfig.platform $HOME/.gitconfig.platform
|
|
||||||
|
|
||||||
brew tap homebrew/core
|
|
||||||
|
|
||||||
printf "Installing xquartz..."
|
|
||||||
#brew cask install xquartz
|
|
||||||
|
|
||||||
brew_packages=(
|
|
||||||
'tree'
|
|
||||||
'openssl'
|
|
||||||
'git'
|
|
||||||
# 'xclip'
|
|
||||||
'rlwrap'
|
|
||||||
'cmake'
|
|
||||||
'pkg-config'
|
|
||||||
'vim'
|
|
||||||
'the_silver_searcher'
|
|
||||||
'selecta'
|
|
||||||
# 'rust'
|
|
||||||
# 'go'
|
|
||||||
'sdl')
|
|
||||||
|
|
||||||
for package in "${brew_packages[@]}"
|
|
||||||
do
|
|
||||||
printf "Installing $package..."
|
|
||||||
ret=$(brew list | awk /$package/)
|
|
||||||
if [[ $ret == $package ]]; then
|
|
||||||
printf "${YELLOW}already installed!${NORMAL}\n"
|
|
||||||
else
|
|
||||||
eval "brew install $package"
|
|
||||||
printf \n
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
printf "\n${YELLOW}Now you must install Xcode.${NORMAL}\n"
|
|
||||||
printf "Open the App Store and install the software.\n"
|
|
||||||
printf "When that finishes open a terminal and run the following:\n"
|
|
||||||
printf " 1. ${YELLOW}sudo xcode-select --install${NORMAL}\n"
|
|
||||||
printf " 2. ${YELLOW}sudo xcodebuild -license${NORMAL}\n"
|
|
||||||
printf " 3. ${YELLOW}sudo xcode-select -s /Applications/Xcode.app/Contents/Developer${NORMAL}\n"
|
|
||||||
|
|
||||||
printf "\n${BOLD}Finished setting up OS X${NORMAL}\n"
|
|
54
osx/pre_install
Executable file
54
osx/pre_install
Executable file
|
@ -0,0 +1,54 @@
|
||||||
|
#!/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)"
|
||||||
|
BOLD="$(tput bold)"
|
||||||
|
NORMAL="$(tput sgr0)"
|
||||||
|
else
|
||||||
|
RED=""
|
||||||
|
GREEN=""
|
||||||
|
YELLOW=""
|
||||||
|
BLUE=""
|
||||||
|
BOLD=""
|
||||||
|
NORMAL=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
printf "Installing Homebrew...\n"
|
||||||
|
|
||||||
|
# OSX 10.11 and earlier will issue certificate errors when Homebrew attempts to download packages
|
||||||
|
# with curl. Detect if we're running on 10.11 or earlier and if so use a fork that passes the
|
||||||
|
# --insecure option to curl.
|
||||||
|
kernel_major="$(uname -r | sed 's/\..*//')"
|
||||||
|
case $kernel_major in
|
||||||
|
15 | 14 | 13) download_patched_homebrew=1 ;;
|
||||||
|
*) download_patched_homebrew=0 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [[ $download_patched_homebrew -eq 1 ]]; then
|
||||||
|
printf "${BOLD}Current MacOS kernel ${NORMAL}${YELLOW}$(uname -r)${NORMAL}${BOLD} requires a patched version of Homebrew...${NORMAL}\n"
|
||||||
|
bash -c "$(curl -fsSL https://raw.githubusercontent.com/sir-pinecone/brew/master/install.sh)"
|
||||||
|
else
|
||||||
|
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
brew tap homebrew/core
|
||||||
|
|
||||||
|
printf "\nInstalling bash...\n"
|
||||||
|
ret=$(brew list | awk /$package/)
|
||||||
|
if [[ $ret == $package ]]; then
|
||||||
|
printf "${YELLOW}Already installed!${NORMAL}\n"
|
||||||
|
else
|
||||||
|
eval "brew install bash"
|
||||||
|
printf "\n${YELLOW}Finished installing updated version of bash.\nYou must now enable it. Run:${NORMAL}\n"
|
||||||
|
printf " ${BOLD}sudo vim /etc/shells${NORMAL}\n"
|
||||||
|
printf "${YELLOW}And add ${NORMAL}${BOLD}/usr/local/bin/bash${NORMAL}${YELLOW} to the end of the list. After that close your terminal and re-run the dotfiles install script.${NORMAL}\n"
|
||||||
|
fi
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
# OSX
|
|
||||||
|
|
||||||
## Setting up Ruby
|
|
||||||
|
|
||||||
* Install rvm
|
|
||||||
* Install bundler
|
|
||||||
* Install Ruby Docs
|
|
||||||
gem install rdoc-data
|
|
||||||
rdoc-data --install
|
|
||||||
gem rdoc --all --overwrite
|
|
||||||
|
|
||||||
## Setup Keyboard
|
|
||||||
|
|
||||||
Map <CapsLock> to <Ctrl> in System Preferences -> Keyboard -> Modifier Keys. Now <caps-c> can leave insert mode.
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
source_helpers="$HOME/.dotfiles/script_helpers"
|
source_helpers="$HOME/.dotfiles/script_helpers"
|
||||||
source "$source_helpers/printing.sh"
|
source "$source_helpers/printing.sh"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------------------------
|
||||||
# API
|
# API
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Requires the printing.sh helper to be sourced.
|
# Requires the printing.sh helper to be sourced.
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Requires the printing.sh helper to be sourced.
|
# Requires the printing.sh helper to be sourced.
|
||||||
# Requires the platform.sh helper to be sourced.
|
# Requires the platform.sh helper to be sourced.
|
||||||
|
@ -165,12 +165,14 @@ link_file() {
|
||||||
echo "expand_symlinks? $expand_symlinks"
|
echo "expand_symlinks? $expand_symlinks"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $expand_symlinks -eq 1 ]]; then
|
if [[ $is_windows -eq 1 ]]; then
|
||||||
source_path=$(expand_path "$source_path")
|
if [[ $expand_symlinks -eq 1 ]]; then
|
||||||
dest_path=$(expand_path "$dest_path")
|
source_path=$(expand_path "$source_path")
|
||||||
else
|
dest_path=$(expand_path "$dest_path")
|
||||||
source_path=$(_clean_link_file_path "$source_path")
|
else
|
||||||
dest_path=$(_clean_link_file_path "$dest_path")
|
source_path=$(_clean_link_file_path "$source_path")
|
||||||
|
dest_path=$(_clean_link_file_path "$dest_path")
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $debug -eq 1 ]]; then
|
if [[ $debug -eq 1 ]]; then
|
||||||
|
@ -210,6 +212,7 @@ link_file() {
|
||||||
echo Link cmd:: $link_cmd
|
echo Link cmd:: $link_cmd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
printf "${BOLD}*${NORMAL} ${YELLOW}Linking '$source_path'${NORMAL} to ${YELLOW}'$dest_path'${NORMAL}\n"
|
||||||
eval $link_cmd
|
eval $link_cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------------------------
|
||||||
# API
|
# API
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
uname_s="$(uname -s)"
|
uname_s="$(uname -s)"
|
||||||
case "${uname_s}" in
|
case "${uname_s}" in
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if which tput >/dev/null 2>&1; then
|
if which tput >/dev/null 2>&1; then
|
||||||
ncolors=$(tput colors)
|
ncolors=$(tput colors)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if which tput >/dev/null 2>&1; then
|
if which tput >/dev/null 2>&1; then
|
||||||
ncolors=$(tput colors)
|
ncolors=$(tput colors)
|
||||||
|
|
346
vimrc
346
vimrc
|
@ -134,11 +134,6 @@ Plug 'nelstrom/vim-qargs' " For the GlobalReplaceIt function (i.e. s
|
||||||
if IsWindows()
|
if IsWindows()
|
||||||
Plug 'suxpert/vimcaps' " Disable capslock (useful if the OS isn't configured to do so).
|
Plug 'suxpert/vimcaps' " Disable capslock (useful if the OS isn't configured to do so).
|
||||||
else
|
else
|
||||||
" Fuzzy search
|
|
||||||
" @incomplete Test out ctrlp for non-Windows setup.
|
|
||||||
" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
|
|
||||||
" Plug 'junegunn/fzf.vim'
|
|
||||||
|
|
||||||
" @fixme Doesn't do anything under Windows...
|
" @fixme Doesn't do anything under Windows...
|
||||||
" Plug 'ervandew/supertab' " Improved autocompletion.
|
" Plug 'ervandew/supertab' " Improved autocompletion.
|
||||||
endif
|
endif
|
||||||
|
@ -332,75 +327,75 @@ imap <right> <nop>
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
|
||||||
augroup campoCmds
|
augroup campoCmds
|
||||||
" Clear all autocmds in the group.
|
" Clear all autocmds in the group.
|
||||||
autocmd!
|
autocmd!
|
||||||
|
|
||||||
" Automatically wrap at N characters.
|
" Automatically wrap at N characters.
|
||||||
autocmd FileType gitcommit setlocal colorcolumn=72
|
autocmd FileType gitcommit setlocal colorcolumn=72
|
||||||
autocmd BufRead,BufNewFile *.{md,txt,plan} execute "setlocal textwidth=" .s:max_line_length
|
autocmd BufRead,BufNewFile *.{md,txt,plan} execute "setlocal textwidth=" .s:max_line_length
|
||||||
|
|
||||||
" Spell checking.
|
" Spell checking.
|
||||||
autocmd FileType gitcommit,markdown,text setlocal spell
|
autocmd FileType gitcommit,markdown,text setlocal spell
|
||||||
|
|
||||||
" Jump to last cursor position unless it's invalid or in an event handler.
|
" Jump to last cursor position unless it's invalid or in an event handler.
|
||||||
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
|
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
|
||||||
|
|
||||||
" Indent HTML <p> tags.
|
" Indent HTML <p> tags.
|
||||||
autocmd FileType html,eruby if g:html_indent_tags !~ '\\|p\>' | let g:html_indent_tags .= '\|p\|li\|dt\|dd' | endif
|
autocmd FileType html,eruby if g:html_indent_tags !~ '\\|p\>' | let g:html_indent_tags .= '\|p\|li\|dt\|dd' | endif
|
||||||
|
|
||||||
" Properly indent schemes (scheme, racket, etc).
|
" Properly indent schemes (scheme, racket, etc).
|
||||||
autocmd bufread,bufnewfile *.{lisp,scm,rkt} setlocal equalprg=scmindent.rkt
|
autocmd bufread,bufnewfile *.{lisp,scm,rkt} setlocal equalprg=scmindent.rkt
|
||||||
|
|
||||||
" Auto reload VIM when settings changed.
|
" Auto reload VIM when settings changed.
|
||||||
autocmd BufWritePost .vimrc so $MYVIMRC
|
autocmd BufWritePost .vimrc so $MYVIMRC
|
||||||
autocmd BufWritePost *.vim so $MYVIMRC
|
autocmd BufWritePost *.vim so $MYVIMRC
|
||||||
autocmd BufWritePost ~/.vimrc.private so $MYVIMRC
|
autocmd BufWritePost ~/.vimrc.private so $MYVIMRC
|
||||||
|
|
||||||
function! s:RunCtags()
|
function! s:RunCtags()
|
||||||
" The ampersand at the end is to make this run in the background. I had to
|
" The ampersand at the end is to make this run in the background. I had to
|
||||||
" group the commands in parens to make the chained commands run in the
|
" group the commands in parens to make the chained commands run in the
|
||||||
" background.
|
" background.
|
||||||
let l:ctags_cmd = "!(ctags --c-types=+l --c++-types=+l --exclude=*.md --exclude=*.txt --exclude=*.config --exclude=*.css --exclude=*.html --exclude=*.htm --exclude=*.json --exclude=node_modules --exclude=.git --exclude=.cache " . g:campo_custom_ctags_args . " -R -o newtags; mv newtags tags) &"
|
let l:ctags_cmd = "!(ctags --c-types=+l --c++-types=+l --exclude=*.md --exclude=*.txt --exclude=*.config --exclude=*.css --exclude=*.html --exclude=*.htm --exclude=*.json --exclude=node_modules --exclude=.git --exclude=.cache " . g:campo_custom_ctags_args . " -R -o newtags; mv newtags tags) &"
|
||||||
exec l:ctags_cmd | redraw!
|
exec l:ctags_cmd | redraw!
|
||||||
endfun
|
endfun
|
||||||
" Generate ctags on save.
|
" Generate ctags on save.
|
||||||
" Also Include local variables for C-like languages.
|
" Also Include local variables for C-like languages.
|
||||||
autocmd BufWritePost *.cs,*.js,*.py,*.c,*.cpp,*.h silent! :call <SID>RunCtags()
|
autocmd BufWritePost *.cs,*.js,*.py,*.c,*.cpp,*.h silent! :call <SID>RunCtags()
|
||||||
|
|
||||||
" Remove trailing whitespace when saving any file.
|
" Remove trailing whitespace when saving any file.
|
||||||
function! s:StripTrailingWhitespaces()
|
function! s:StripTrailingWhitespaces()
|
||||||
if g:campo_strip_trailing_whitespace
|
if g:campo_strip_trailing_whitespace
|
||||||
let l = line(".")
|
let l = line(".")
|
||||||
let c = col(".")
|
let c = col(".")
|
||||||
%s/\s\+$//e
|
%s/\s\+$//e
|
||||||
call cursor(l, c)
|
call cursor(l, c)
|
||||||
endif
|
endif
|
||||||
endfun
|
endfun
|
||||||
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
|
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
|
||||||
|
|
||||||
"////////////////////////////////////////////////////////////////
|
"////////////////////////////////////////////////////////////////
|
||||||
" FILE TEMPLATES
|
" FILE TEMPLATES
|
||||||
"////////////////////////////////////////////////////////////////
|
"////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
" Shell script template.
|
" Shell script template.
|
||||||
autocmd BufNewFile *.sh 0r ~/.vim/templates/skeleton.sh
|
autocmd BufNewFile *.sh 0r ~/.vim/templates/skeleton.sh
|
||||||
autocmd BufNewFile *.plan 0r ~/.vim/templates/skeleton.plan
|
autocmd BufNewFile *.plan 0r ~/.vim/templates/skeleton.plan
|
||||||
|
|
||||||
" C/C++ template.
|
" C/C++ template.
|
||||||
autocmd bufnewfile *.{c,cc,cpp,h,hpp} 0r ~/.vim/templates/c_header_notice
|
autocmd bufnewfile *.{c,cc,cpp,h,hpp} 0r ~/.vim/templates/c_header_notice
|
||||||
autocmd bufnewfile *.{c,cc,cpp,h,hpp} exe "2," . 6 . "g/File:.*/s//File: " .expand("%")
|
autocmd bufnewfile *.{c,cc,cpp,h,hpp} exe "2," . 6 . "g/File:.*/s//File: " .expand("%")
|
||||||
autocmd bufnewfile *.{c,cc,cpp,h,hpp} exe "2," . 6 . "g/Creation Date:.*/s//Creation Date: " .strftime("%Y-%m-%d")
|
autocmd bufnewfile *.{c,cc,cpp,h,hpp} exe "2," . 6 . "g/Creation Date:.*/s//Creation Date: " .strftime("%Y-%m-%d")
|
||||||
autocmd bufnewfile *.{c,cc,cpp,h,hpp} exe "2," . 6 . "g/$year/s//" .strftime("%Y")
|
autocmd bufnewfile *.{c,cc,cpp,h,hpp} exe "2," . 6 . "g/$year/s//" .strftime("%Y")
|
||||||
function! s:InsertHeaderGates()
|
function! s:InsertHeaderGates()
|
||||||
let gatename = substitute(toupper(expand("%:t")), "\\.", "_", "g")
|
let gatename = substitute(toupper(expand("%:t")), "\\.", "_", "g")
|
||||||
execute "normal! ggO#ifndef " . gatename
|
execute "normal! ggO#ifndef " . gatename
|
||||||
normal! Go
|
normal! Go
|
||||||
normal! Go
|
normal! Go
|
||||||
execute "normal! Go#define " . gatename . " "
|
execute "normal! Go#define " . gatename . " "
|
||||||
execute "normal! o#endif"
|
execute "normal! o#endif"
|
||||||
normal! kkk
|
normal! kkk
|
||||||
endfunction
|
endfunction
|
||||||
autocmd bufnewfile *.{h,hpp} call <SID>InsertHeaderGates()
|
autocmd bufnewfile *.{h,hpp} call <SID>InsertHeaderGates()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
@ -446,16 +441,16 @@ map Q <Nop>
|
||||||
|
|
||||||
" Open a terminal within vim. Use `exit` to close it.
|
" Open a terminal within vim. Use `exit` to close it.
|
||||||
if exists(':terminal')
|
if exists(':terminal')
|
||||||
map <leader>t :terminal<cr>
|
map <leader>t :terminal<cr>
|
||||||
tnoremap <leader>e <C-\><C-n>
|
tnoremap <leader>e <C-\><C-n>
|
||||||
tnoremap <A-h> <C-\><C-n><C-w>h
|
tnoremap <A-h> <C-\><C-n><C-w>h
|
||||||
tnoremap <A-j> <C-\><C-n><C-w>j
|
tnoremap <A-j> <C-\><C-n><C-w>j
|
||||||
tnoremap <A-k> <C-\><C-n><C-w>k
|
tnoremap <A-k> <C-\><C-n><C-w>k
|
||||||
tnoremap <A-l> <C-\><C-n><C-w>l
|
tnoremap <A-l> <C-\><C-n><C-w>l
|
||||||
nnoremap <A-h> <C-w>h
|
nnoremap <A-h> <C-w>h
|
||||||
nnoremap <A-j> <C-w>j
|
nnoremap <A-j> <C-w>j
|
||||||
nnoremap <A-k> <C-w>k
|
nnoremap <A-k> <C-w>k
|
||||||
nnoremap <A-l> <C-w>l
|
nnoremap <A-l> <C-w>l
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Jump to other buffers.
|
" Jump to other buffers.
|
||||||
|
@ -493,7 +488,7 @@ map <leader>= z=
|
||||||
|
|
||||||
" Clear the search buffer (highlighting) when hitting return.
|
" Clear the search buffer (highlighting) when hitting return.
|
||||||
function! MapCR()
|
function! MapCR()
|
||||||
nnoremap <cr> :nohlsearch<cr>
|
nnoremap <cr> :nohlsearch<cr>
|
||||||
endfunction
|
endfunction
|
||||||
call MapCR()
|
call MapCR()
|
||||||
nnoremap <leader><leader> <c-^>
|
nnoremap <leader><leader> <c-^>
|
||||||
|
@ -514,10 +509,10 @@ nnoremap <c-g> :%s///g<left><left>
|
||||||
"////////////////////////////////////////////////////////////////
|
"////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
function! s:CompleteFilenameWithoutExtension(ArgLead, CmdLine, CursorPos)
|
function! s:CompleteFilenameWithoutExtension(ArgLead, CmdLine, CursorPos)
|
||||||
" Returns a matching filename without the period that separates the name
|
" Returns a matching filename without the period that separates the name
|
||||||
" from the extension.
|
" from the extension.
|
||||||
let l:file = substitute(glob(a:ArgLead.'*', 0, 0), "[\.].*", "", "*")
|
let l:file = substitute(glob(a:ArgLead.'*', 0, 0), "[\.].*", "", "*")
|
||||||
return l:file
|
return l:file
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Custom command to open cpp and h files without typing an extension
|
" Custom command to open cpp and h files without typing an extension
|
||||||
|
@ -681,9 +676,9 @@ let s:light_rainbow = ['red', 'green', 'magenta', 'cyan', 'yellow', 'white', 'gr
|
||||||
let s:dark_rainbow = ['darkblue', 'red', 'black', 'darkgreen', 'darkyellow', 'darkred', 'darkgray']
|
let s:dark_rainbow = ['darkblue', 'red', 'black', 'darkgreen', 'darkyellow', 'darkred', 'darkgray']
|
||||||
|
|
||||||
function! UpdateRainbowConf()
|
function! UpdateRainbowConf()
|
||||||
let g:rainbow_conf = {
|
let g:rainbow_conf = {
|
||||||
\ 'ctermfgs': (s:rainbow_theme == "light"? s:dark_rainbow : s:light_rainbow)
|
\ 'ctermfgs': (s:rainbow_theme == "light"? s:dark_rainbow : s:light_rainbow)
|
||||||
\}
|
\}
|
||||||
"\ 'separately': {
|
"\ 'separately': {
|
||||||
"\ '*': 0, " Disable all
|
"\ '*': 0, " Disable all
|
||||||
"\ 'c++': {} " Only enable c++
|
"\ 'c++': {} " Only enable c++
|
||||||
|
@ -693,18 +688,18 @@ endfunction
|
||||||
call UpdateRainbowConf()
|
call UpdateRainbowConf()
|
||||||
|
|
||||||
function! ReloadRainbow()
|
function! ReloadRainbow()
|
||||||
if g:campo_theme_use_rainbow_parens
|
if g:campo_theme_use_rainbow_parens
|
||||||
if exists(':RainbowToggle')
|
if exists(':RainbowToggle')
|
||||||
call UpdateRainbowConf()
|
call UpdateRainbowConf()
|
||||||
call rainbow#clear() | call rainbow#hook()
|
call rainbow#clear() | call rainbow#hook()
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
let g:rainbow_active = 0
|
||||||
|
if exists(':RainbowToggle')
|
||||||
|
call UpdateRainbowConf()
|
||||||
|
call rainbow#clear()
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
else
|
|
||||||
let g:rainbow_active = 0
|
|
||||||
if exists(':RainbowToggle')
|
|
||||||
call UpdateRainbowConf()
|
|
||||||
call rainbow#clear()
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
@ -731,19 +726,19 @@ set tags+=tags;$HOME
|
||||||
" CENTER THE BUFFER
|
" CENTER THE BUFFER
|
||||||
"////////////////////////////////////////////////////////////////
|
"////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
function! CenterPane()
|
function! CenterPane()
|
||||||
" centers the current pane as the middle 2 of 4 imaginary columns
|
" centers the current pane as the middle 2 of 4 imaginary columns
|
||||||
" should be called in a window with a single pane
|
" should be called in a window with a single pane
|
||||||
" Taken from https://dev.to/vinneycavallo/easily-center-content-in-vim
|
" Taken from https://dev.to/vinneycavallo/easily-center-content-in-vim
|
||||||
lefta vnew
|
lefta vnew
|
||||||
wincmd w
|
wincmd w
|
||||||
exec 'vertical resize '. string(&columns * 0.75)
|
exec 'vertical resize '. string(&columns * 0.75)
|
||||||
endfunction
|
endfunction
|
||||||
nnoremap <leader>c :call CenterPane()<cr>
|
nnoremap <leader>c :call CenterPane()<cr>
|
||||||
|
|
||||||
function! RemoveCenterPane()
|
function! RemoveCenterPane()
|
||||||
wincmd w
|
wincmd w
|
||||||
close
|
close
|
||||||
endfunction
|
endfunction
|
||||||
nnoremap <leader>cw :call RemoveCenterPane()<cr>
|
nnoremap <leader>cw :call RemoveCenterPane()<cr>
|
||||||
|
|
||||||
|
@ -772,24 +767,24 @@ map <leader>l :call ChangeBgTheme('light', 0)<cr>
|
||||||
map <leader>ll :call ChangeBgTheme('dark', 0)<cr>
|
map <leader>ll :call ChangeBgTheme('dark', 0)<cr>
|
||||||
|
|
||||||
function! ChangeBgTheme(bg, onlySetTheme)
|
function! ChangeBgTheme(bg, onlySetTheme)
|
||||||
if a:bg =~ 'light'
|
if a:bg =~ 'light'
|
||||||
let s:rainbow_theme = 'light'
|
let s:rainbow_theme = 'light'
|
||||||
let s:theme = g:campo_light_theme
|
let s:theme = g:campo_light_theme
|
||||||
exe 'colorscheme ' . s:theme
|
exe 'colorscheme ' . s:theme
|
||||||
set background=light
|
set background=light
|
||||||
else
|
else
|
||||||
let s:rainbow_theme = 'dark'
|
let s:rainbow_theme = 'dark'
|
||||||
let s:theme = g:campo_dark_theme
|
let s:theme = g:campo_dark_theme
|
||||||
" We have to set the theme twice in order to get its correct dark-theme colors.
|
" We have to set the theme twice in order to get its correct dark-theme colors.
|
||||||
" Weird stuff.
|
" Weird stuff.
|
||||||
exe 'colorscheme ' . s:theme
|
exe 'colorscheme ' . s:theme
|
||||||
set background=dark
|
set background=dark
|
||||||
exe 'colorscheme ' . s:theme
|
exe 'colorscheme ' . s:theme
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !a:onlySetTheme
|
if !a:onlySetTheme
|
||||||
exec ':AirlineTheme ' . a:bg
|
exec ':AirlineTheme ' . a:bg
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
if s:default_bg =~ 'light'
|
if s:default_bg =~ 'light'
|
||||||
|
@ -878,35 +873,35 @@ set errorformat+=\\\ %#%f(%l)\ :\ %#%t%[A-z]%#\ %m
|
||||||
set errorformat+=\\\ %#%f(%l\\\,%c-%*[0-9]):\ %#%t%[A-z]%#\ %m
|
set errorformat+=\\\ %#%f(%l\\\,%c-%*[0-9]):\ %#%t%[A-z]%#\ %m
|
||||||
|
|
||||||
function! HideBuildResultsAndClearErrors()
|
function! HideBuildResultsAndClearErrors()
|
||||||
RemoveErrorMarkers
|
RemoveErrorMarkers
|
||||||
call asyncrun#quickfix_toggle(g:quickfix_window_height, 0)
|
call asyncrun#quickfix_toggle(g:quickfix_window_height, 0)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! HideAsyncResults()
|
function! HideAsyncResults()
|
||||||
call asyncrun#quickfix_toggle(g:quickfix_window_height, 0)
|
call asyncrun#quickfix_toggle(g:quickfix_window_height, 0)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ToggleBuildResults()
|
function! ToggleBuildResults()
|
||||||
call asyncrun#quickfix_toggle(g:quickfix_window_height)
|
call asyncrun#quickfix_toggle(g:quickfix_window_height)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! StopRunTask()
|
function! StopRunTask()
|
||||||
AsyncStop
|
AsyncStop
|
||||||
call HideAsyncResults()
|
call HideAsyncResults()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ExecuteRunScript()
|
function! ExecuteRunScript()
|
||||||
exec "AsyncRun! -post=call\\ StopRunTask() ./run %"
|
exec "AsyncRun! -post=call\\ StopRunTask() ./run %"
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SilentBuild()
|
function! SilentBuild()
|
||||||
AsyncStop
|
AsyncStop
|
||||||
exec "AsyncRun! -save=2 -post=call\\ HideAsyncResults() ./build* %"
|
exec "AsyncRun! -save=2 -post=call\\ HideAsyncResults() ./build* %"
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Show results window the moment the async job starts
|
" Show results window the moment the async job starts
|
||||||
augroup vimrc
|
augroup vimrc
|
||||||
autocmd User AsyncRunStart call asyncrun#quickfix_toggle(g:quickfix_window_height, 1)
|
autocmd User AsyncRunStart call asyncrun#quickfix_toggle(g:quickfix_window_height, 1)
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Toggle build results
|
" Toggle build results
|
||||||
|
@ -939,35 +934,23 @@ nnoremap <C-p> :cp<CR>
|
||||||
" SEARCH
|
" SEARCH
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
|
||||||
" @incomplete
|
|
||||||
if !IsWindows()
|
|
||||||
let rg_args = "--column --line-number --no-heading --fixed-strings --ignore-case --no-ignore --hidden --follow --pretty \"always\" " . g:campo_custom_search_args
|
|
||||||
let cmd = "command! -bang -nargs=* Find call fzf#vim#grep('rg " . rg_args . "'.shellescape(<q-args>), 1, <bang>0)"
|
|
||||||
exec cmd
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Search using ripgrep (first install with Rust: cargo install ripgrep).
|
" Search using ripgrep (first install with Rust: cargo install ripgrep).
|
||||||
function! Search(case_sensitive)
|
function! Search(case_sensitive)
|
||||||
let helper = "[" . (a:case_sensitive ? "case-sensitive" : "case-insensitive") . "] search: "
|
let l:helper = "[" . (a:case_sensitive ? "case-sensitive" : "case-insensitive") . "] search: "
|
||||||
let term = input(helper)
|
let l:term = input(l:helper)
|
||||||
if empty(term)
|
if empty(l:term)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"@note --pretty (i.e. colors) is not enabled in vim-ripgrep because the
|
"@note --pretty (i.e. colors) is not enabled in vim-ripgrep because the
|
||||||
"quickfix window doesn't seem to parse the ansi color codes.
|
"quickfix window doesn't seem to parse the ansi color codes.
|
||||||
let rg_args = "--trim -g \"!tags\" " . g:campo_custom_search_args
|
let l:rg_args = "--column --line-number --no-heading --fixed-strings --no-ignore --hidden --follow --trim -g \"!tags\" " . g:campo_custom_search_args
|
||||||
|
|
||||||
if !a:case_sensitive
|
if !a:case_sensitive
|
||||||
let rg_args .= " --ignore-case"
|
let l:rg_args .= " --ignore-case"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if IsWindows()
|
exec 'Rg ' . l:rg_args . ' "' . l:term . '"'
|
||||||
exec 'Rg ' . rg_args . ' "' . term . '"'
|
|
||||||
else
|
|
||||||
" @incomplete Test out ripgrep on non-Windows OS
|
|
||||||
echo "Not implemented"
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
map <leader>s :call Search(0)<cr>
|
map <leader>s :call Search(0)<cr>
|
||||||
map <leader>ss :call Search(1)<cr>
|
map <leader>ss :call Search(1)<cr>
|
||||||
|
@ -978,45 +961,44 @@ map <leader>ss :call Search(1)<cr>
|
||||||
nnoremap <expr> o (&buftype is# "quickfix" ? "<CR>\|:lopen<CR>" : "o")
|
nnoremap <expr> o (&buftype is# "quickfix" ? "<CR>\|:lopen<CR>" : "o")
|
||||||
nnoremap <expr> p (&buftype is# "quickfix" ? "<CR>\|:copen<CR>" : "p")
|
nnoremap <expr> p (&buftype is# "quickfix" ? "<CR>\|:copen<CR>" : "p")
|
||||||
|
|
||||||
|
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
" SEARCH & REPLACE
|
" SEARCH & REPLACE
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
|
||||||
" Replace the selected text in all files within the repo.
|
" Replace the selected text in all files within the repo.
|
||||||
function! GlobalReplaceIt(confirm_replacement)
|
function! GlobalReplaceIt(confirm_replacement)
|
||||||
if exists(':Ggrep')
|
if exists(':Ggrep')
|
||||||
call inputsave()
|
call inputsave()
|
||||||
|
|
||||||
if a:confirm_replacement
|
if a:confirm_replacement
|
||||||
let l:term = input('Enter search term (w/ confirmation): ')
|
let l:term = input('Enter search term (w/ confirmation): ')
|
||||||
|
else
|
||||||
|
let l:term = input('Enter search term (no confirmation): ')
|
||||||
|
endif
|
||||||
|
|
||||||
|
call inputrestore()
|
||||||
|
if empty(l:term)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
call inputsave()
|
||||||
|
let l:replacement = input('Enter replacement: ')
|
||||||
|
call inputrestore()
|
||||||
|
if empty(l:replacement)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
if a:confirm_replacement
|
||||||
|
let l:confirm_opt = 'c'
|
||||||
|
else
|
||||||
|
let l:confirm_opt = 'e'
|
||||||
|
endif
|
||||||
|
|
||||||
|
execute 'Ggrep '.l:term
|
||||||
|
execute 'Qargs | argdo %s/'.l:term.'/'.l:replacement.'/g'.l:confirm_opt.' | update'
|
||||||
else
|
else
|
||||||
let l:term = input('Enter search term (no confirmation): ')
|
echo "Unable to search since you're not in a git repo"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call inputrestore()
|
|
||||||
if empty(l:term)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
call inputsave()
|
|
||||||
let l:replacement = input('Enter replacement: ')
|
|
||||||
call inputrestore()
|
|
||||||
if empty(l:replacement)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
if a:confirm_replacement
|
|
||||||
let l:confirm_opt = 'c'
|
|
||||||
else
|
|
||||||
let l:confirm_opt = 'e'
|
|
||||||
endif
|
|
||||||
|
|
||||||
execute 'Ggrep '.l:term
|
|
||||||
execute 'Qargs | argdo %s/'.l:term.'/'.l:replacement.'/g'.l:confirm_opt.' | update'
|
|
||||||
else
|
|
||||||
echo "Unable to search since you're not in a git repo"
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
map <leader>r :call GlobalReplaceIt(0)<cr>
|
map <leader>r :call GlobalReplaceIt(0)<cr>
|
||||||
map <leader>rr :call GlobalReplaceIt(1)<cr>
|
map <leader>rr :call GlobalReplaceIt(1)<cr>
|
||||||
|
|
|
@ -159,7 +159,7 @@ processor time and is generally useless.
|
||||||
|
|
||||||
### Setting up Custom Search
|
### Setting up Custom Search
|
||||||
|
|
||||||
* First install Rusto. See `Setting up Rust` below.
|
* First install Rust. See `Setting up Rust` below.
|
||||||
* Setup `ripgrep`:
|
* Setup `ripgrep`:
|
||||||
* Open an `msvc x64` shell and run `cargo install ripgrep`. **Note** the last time I did this
|
* Open an `msvc x64` shell and run `cargo install ripgrep`. **Note** the last time I did this
|
||||||
I got linker errors saying that it was trying to link an x86 exe in a 64-bit env. I had to run
|
I got linker errors saying that it was trying to link an x86 exe in a 64-bit env. I had to run
|
||||||
|
|
18
zlogin
18
zlogin
|
@ -1,11 +1,7 @@
|
||||||
# go to saved path if there is one
|
# Need to edit the path again here so that we can get the homebrew bin folder
|
||||||
if [[ -f ~/.current_path~ ]]; then
|
# ahead of everything else. This is necessary because zsh is modifying the path
|
||||||
cd `cat ~/.current_path~`
|
# in zshrc, and that causes us to run out of /usr/bin for programs that we want
|
||||||
rm ~/.current_path~
|
# to use from homebrew's bin
|
||||||
fi
|
#
|
||||||
|
# Update 2020-07-25: This no longer seems to be an issue.
|
||||||
# Need to edit the path again here so that we can get the homebrew bin folder ahead of
|
#path=(/usr/local/bin /usr/local/sbin /usr/local/opt/openssl/bin $path)
|
||||||
# everything else. This is necessary because zsh is modifying the path in zshrc, and
|
|
||||||
# that causes us to run out of /usr/bin for programs that we want to use from homebrew's
|
|
||||||
# bin
|
|
||||||
path=($HOME/homebrew/opt/openssl/bin $HOME/homebrew/sbin $HOME/homebrew/bin $path)
|
|
||||||
|
|
21
zshenv
21
zshenv
|
@ -1,10 +1,4 @@
|
||||||
platform=`uname -s`
|
platform=`uname -s`
|
||||||
kernel_release=`uname -r`
|
|
||||||
|
|
||||||
test -f ~/.aliases.private && . ~/.aliases.private
|
|
||||||
# Common env must come first.
|
|
||||||
test -f ~/.private-dotfiles.common/env && . ~/.private-dotfiles.common/env
|
|
||||||
test -f ~/.private-dotfiles/env && . ~/.private-dotfiles/env
|
|
||||||
|
|
||||||
# Unbreak broken, non-colored terminal
|
# Unbreak broken, non-colored terminal
|
||||||
export TERM=xterm-256color
|
export TERM=xterm-256color
|
||||||
|
@ -17,11 +11,10 @@ export HOMEBREW_NO_ANALYTICS=1
|
||||||
export HOMEBREW_NO_INSECURE_REDIRECT=1
|
export HOMEBREW_NO_INSECURE_REDIRECT=1
|
||||||
export HOMEBREW_CASK_OPTS=--require-sha
|
export HOMEBREW_CASK_OPTS=--require-sha
|
||||||
|
|
||||||
# Grep tweaks
|
# Ruby
|
||||||
export GREP_OPTIONS="-nRi --color --exclude-dir=.git --exclude-dir=tmp --exclude-dir=log --exclude-dir=node_modules --exclude-dir=bower_components --exclude-dir=coverage --exclude-dir=.bundle --exclude=*.csv --exclude=*.pdf --exclude-dir=vendor --exclude-dir=rdoc --exclude-dir=target --exclude-dir=personal --exclude-dir=resources/public/js/*.*" # --exclude-dir=images --exclude-dir=coverage
|
|
||||||
|
|
||||||
export RBENV_PATH="$HOME/.rbenv"
|
export RBENV_PATH="$HOME/.rbenv"
|
||||||
|
|
||||||
|
# Clojure
|
||||||
export LEIN_FAST_TRAMPOLINE=y
|
export LEIN_FAST_TRAMPOLINE=y
|
||||||
|
|
||||||
if [[ $platform == 'Linux' ]]; then
|
if [[ $platform == 'Linux' ]]; then
|
||||||
|
@ -32,16 +25,6 @@ if [[ $platform == 'Linux' ]]; then
|
||||||
export LOLCOMMITS_DIR="/shared/Dev/lolcommits"
|
export LOLCOMMITS_DIR="/shared/Dev/lolcommits"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
path=($HOME/bin $HOME/.dotfiles/bin ${RBENV_PATH}/bin $HOME/.vim/scripts $path)
|
|
||||||
|
|
||||||
if [[ $platform == 'Darwin' ]]; then
|
|
||||||
test -f $HOME/.cargo && source $HOME/.cargo/env
|
|
||||||
# TODO: test for qt
|
|
||||||
if [ -d "$HOME/Qt" ]; then
|
|
||||||
path=($HOME/Qt/5.8/clang_64/bin $path)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d "$HOME/.rbenv" ]; then
|
if [ -d "$HOME/.rbenv" ]; then
|
||||||
# Start rbenv
|
# Start rbenv
|
||||||
eval "$(rbenv init -)"
|
eval "$(rbenv init -)"
|
||||||
|
|
15
zshrc
15
zshrc
|
@ -90,8 +90,19 @@ bindkey -e
|
||||||
source $ZSH/lib/*.zsh
|
source $ZSH/lib/*.zsh
|
||||||
|
|
||||||
# Source my custom files after oh-my-zsh so I can override things.
|
# Source my custom files after oh-my-zsh so I can override things.
|
||||||
source $HOME/.env.platform
|
test -f $HOME/.aliases && . $HOME/.aliases
|
||||||
source $HOME/.aliases
|
test -f $HOME/.aliases.private && . $HOME/.aliases.private
|
||||||
|
# Common env must come first.
|
||||||
|
test -f $HOME/.private-dotfiles.common/env && . $HOME/.private-dotfiles.common/env
|
||||||
|
test -f $HOME/.private-dotfiles/env && . $HOME/.private-dotfiles/env
|
||||||
|
|
||||||
|
if [[ -d "$HOME/bin" ]]; then
|
||||||
|
export PATH=$HOME/bin/:$PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -d "$HOME/.dotfiles/bin" ]]; then
|
||||||
|
export PATH=$HOME/.dotfiles/bin/:$PATH
|
||||||
|
fi
|
||||||
|
|
||||||
# Fix <c-h> in neovim
|
# Fix <c-h> in neovim
|
||||||
infocmp $TERM | sed 's/kbs=^[hH]/kbs=\\177/' > $HOME/.$TERM.ti
|
infocmp $TERM | sed 's/kbs=^[hH]/kbs=\\177/' > $HOME/.$TERM.ti
|
||||||
|
|
Loading…
Reference in New Issue
Block a user