Taylor Bockman
1 year ago
commit
299e686095
12 changed files with 539 additions and 0 deletions
@ -0,0 +1,31 @@
|
||||
# ZSH Configuration |
||||
|
||||
The ZSH configuration is completely modularized to make management easier. The following are brief descriptions of each |
||||
file: |
||||
|
||||
* `zshrc`: The main ZSH configuration sourced for non-login interactive terminals. |
||||
* `zprofile`: The main ZSH configuration sourced for login interactive terminals. Also sources `zshrc`. |
||||
* `functions.zsh`: A file containing function definitions for utilities. |
||||
* `aliases.zsh`: A file containing aliases sourced into the terminal. |
||||
* `exports.zsh`: A file containing all exports not found in `zprofile`. |
||||
* `initializations.zsh`: A file containing initialization code for various tasks such as RVM directories, pyenv, etc. |
||||
* `ps1.zsh`: Defines the terminal prompt. |
||||
|
||||
## Supported Other Files |
||||
|
||||
Private variables will be automatically sourced from `$HOME/.private`,`$HOME/.bash_private` or `HOME/.zsh_private`. |
||||
|
||||
`$HOME/.inputrc` can be used for special input configurations (for example terminal editors require special terminal settings.) |
||||
|
||||
Operating system specific settings can be placed in `.linuxrc` or `.macrc` respectively. |
||||
|
||||
## Git Completion |
||||
|
||||
Git completion is automatically installed on first run to `.zsh` in the users home. This is all created for you and nothing |
||||
needs to be done. Should the curl commands fail to pull the correct files from the `git` github repository you will need |
||||
to source both `git-completion.bash` and `git-completion.zsh` and adjust the script appropriately or place them in a |
||||
`.zsh` directory in `$HOME`. |
||||
|
||||
## Syntax Highlighting |
||||
|
||||
If your ZSH version is greater than or equal to 4.11.3 fish-like syntax highlighting will be installed. |
@ -0,0 +1,58 @@
|
||||
# Alias |
||||
if [[ "$OS_TYPE" != "gnu-linux" ]]; then |
||||
alias python='python3' |
||||
fi |
||||
|
||||
# rlwrap provides readline wrapping for programs. |
||||
# This alias makes the SBCL REPL usable. |
||||
alias sbcl='rlwrap sbcl' |
||||
|
||||
# Useful git aliases |
||||
alias gita='git add' |
||||
alias gitap='git add -p' |
||||
alias gitc='git commit' |
||||
alias gitp='git push' |
||||
alias gits='git status' |
||||
alias gitd='git diff' |
||||
|
||||
alias k8='kubectl' |
||||
|
||||
# Good overrides |
||||
|
||||
# Don't nuke the computer |
||||
alias rm='rm -i' |
||||
|
||||
# Confirm before overwriting |
||||
alias cp='cp -i' |
||||
|
||||
# Default free to sizes in megabytes |
||||
alias free='free -m' |
||||
|
||||
# Better ls - lists more information for each file |
||||
alias ll='ls -lh' |
||||
|
||||
# Less is a better more |
||||
alias more=less |
||||
|
||||
# df in human readable sizes |
||||
alias df='df -h' |
||||
|
||||
# I use Neovim |
||||
if [ -x "$(command -v nvim)" ]; then |
||||
alias vim=nvim |
||||
fi |
||||
|
||||
# Human readable ls for the current directory |
||||
if [[ "$OS_TYPE" != "gnu-linux" ]]; then |
||||
# OS X lt |
||||
alias lt='du -sh * | sort -h' |
||||
else |
||||
alias lt='ls --human-readable --size -1 -S --classify' |
||||
fi |
||||
|
||||
|
||||
# Count files in the current directory |
||||
alias count='find . -type f | wc -l' |
||||
|
||||
# Generate sha1 hashes on the fly |
||||
alias sha1='openssl sha1' |
@ -0,0 +1,58 @@
|
||||
#!/bin/zsh |
||||
|
||||
if hash vim 2>/dev/null; then |
||||
export EDITOR=vim |
||||
else |
||||
export EDITOR=vi |
||||
fi |
||||
|
||||
if hash clang 2>/dev/null; then |
||||
export CC=$(which clang) |
||||
else |
||||
export CC=$(which gcc) |
||||
fi |
||||
|
||||
if hash clang++ 2>/dev/null; then |
||||
export CXX=$(which clang++) |
||||
else |
||||
export CXX=$(which g++) |
||||
fi |
||||
|
||||
export OPENSSL_ROOT_DIR=$(which openssl) |
||||
|
||||
# Add openJDK to path |
||||
export PATH="/usr/local/opt/openjdk/bin:$PATH" |
||||
|
||||
# Ignore duplicates in history to make history less of a hassle to use. |
||||
export HISTCONTROL=ignoredups |
||||
|
||||
# If go is installed, set the $GOPATH to the projects directory created above. |
||||
if which go > /dev/null; then |
||||
export GOPATH=$HOME/.go |
||||
export PATH=${PATH}:`go env GOPATH`/bin |
||||
fi |
||||
|
||||
if [ -d "$HOME/.rvm" ]; then |
||||
export PATH="$PATH:$HOME/.rvm/bin" |
||||
fi |
||||
|
||||
if [ -f "$HOME/.cargo/env" ]; then |
||||
. "$HOME/.cargo/env" |
||||
fi |
||||
|
||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then |
||||
# If the Go install guide was followed for Linux |
||||
# /usr/local/go will contain the go binary. |
||||
export PATH=$PATH:/usr/local/go/bin |
||||
fi |
||||
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then |
||||
# Enable homebrew openssl support |
||||
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/ |
||||
export PATH="/usr/local/opt/llvm/bin:$PATH" |
||||
export PATH="/usr/local/opt/qt/bin:$PATH" |
||||
export PATH="/usr/local/opt/tcl-tk/bin:$PATH" |
||||
fi |
||||
|
||||
export PATH=$HOME/bin:/usr/local/bin:$PATH |
||||
|
@ -0,0 +1,12 @@
|
||||
#!/usr/zsh |
||||
|
||||
parse_git_branch() { |
||||
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /' |
||||
} |
||||
|
||||
# If you ever needed weather... |
||||
weather() { |
||||
curl wttr.in |
||||
} |
||||
|
||||
|
@ -0,0 +1,30 @@
|
||||
#!/bin/zsh |
||||
|
||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then |
||||
export PATH=/usr/local/bin:$PATH |
||||
export PYENV_ROOT="$HOME/.pyenv" |
||||
export PATH="$PYENV_ROOT/bin:$PATH" |
||||
|
||||
# For whatever reason the linux version of pyenv doesnt install `pyenv-virtualenv-init`. |
||||
eval "$(pyenv init -)" |
||||
eval "$(pyenv virtualenv-init -)" |
||||
fi |
||||
|
||||
if which pyenv-virtualenv-init > /dev/null; then |
||||
export PATH=/usr/local/bin:$PATH |
||||
export PYENV_ROOT="$HOME/.pyenv" |
||||
export PATH="$PYENV_ROOT/bin:$PATH" |
||||
eval "$(pyenv init -)" |
||||
eval "$(pyenv virtualenv-init -)" |
||||
fi |
||||
|
||||
|
||||
if hash pyenv 2>/dev/null; then |
||||
export PYENV_ROOT="$HOME/.pyenv" |
||||
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" |
||||
eval "$(pyenv init -)" |
||||
fi |
||||
|
||||
|
||||
# RVM configuration |
||||
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" |
@ -0,0 +1,8 @@
|
||||
# In here you can define various keybinds for any |
||||
# given setup. Just wrap them with the appropriate checks. |
||||
|
||||
# Bind caps lock to escape if `xmodmap` exists |
||||
if type "xmodmap" > /dev/null; then |
||||
xmodmap -e "clear lock" #disable caps lock switch |
||||
xmodmap -e "keysym Caps_Lock = Escape" #set caps_lock as escape |
||||
fi |
@ -0,0 +1,10 @@
|
||||
#!/bin/zsh |
||||
|
||||
setopt prompt_subst |
||||
autoload -Uz vcs_info |
||||
precmd () { vcs_info } |
||||
|
||||
# Format = [<branch>] |
||||
zstyle ':vcs_info:*' formats ' %F{green}[%b]%f' |
||||
|
||||
PS1='%B%n@%m%b %F{blue}%2~%f${vcs_info_msg_0_} %B⇨%b ' |
@ -0,0 +1,109 @@
|
||||
#! /usr/bin/env bash |
||||
|
||||
name=$1 |
||||
cmake_version=$2 |
||||
c_standard=$3 |
||||
|
||||
# Finds the directory of this script |
||||
if [[ "$OS_TYPE" == "linux-gnu" ]]; then |
||||
script_dir=$(cd "$( dirname "`readlink -f ${BASH_SOURCE[0]}`")" && pwd) |
||||
else |
||||
script_dir=$(cd "$( dirname "`greadlink -f ${BASH_SOURCE[0]}`")" && pwd) |
||||
fi |
||||
|
||||
if [ -z $name ] |
||||
then |
||||
echo "Name must be specified" |
||||
echo "" |
||||
echo "./cgen.sh <name> [cmake version] [C Standard]" |
||||
exit -1 |
||||
fi |
||||
|
||||
if [ -z $cmake_version ] |
||||
then |
||||
echo "No CMake version supplied...defaulting to 3.15" |
||||
cmake_version="3.15" |
||||
fi |
||||
|
||||
if [ -z $c_standard ] |
||||
then |
||||
echo "No C Standard supplied...defaulting to 11" |
||||
c_standard="11" |
||||
fi |
||||
|
||||
mkdir $name |
||||
mkdir $name/src |
||||
mkdir $name/include |
||||
|
||||
cmake_config=$name/CMakeLists.txt |
||||
|
||||
touch $cmake_config |
||||
|
||||
echo "cmake_minimum_required(VERSION $cmake_version)" >> $cmake_config |
||||
echo "project($name)" >> $cmake_config |
||||
echo "" >> $cmake_config |
||||
echo "set (CMAKE_C_STANDARD $c_standard)" >> $cmake_config |
||||
echo "" >> $cmake_config |
||||
echo "# Output to bin and lib" >> $cmake_config |
||||
echo "set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY \${CMAKE_BINARY_DIR}/lib)" >> $cmake_config |
||||
echo "set(CMAKE_LIBRARY_OUTPUT_DIRECTORY \${CMAKE_BINARY_DIR}/lib)" >> $cmake_config |
||||
echo "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \${CMAKE_BINARY_DIR}/bin)" >> $cmake_config |
||||
echo "" >> $cmake_config |
||||
echo "" >> $cmake_config |
||||
echo "# The following lines enable compile_commands.json and dump it in the root of the project" >> $cmake_config |
||||
echo "# This is needed for clangd and lsp to work" >> $cmake_config |
||||
echo "" >> $cmake_config |
||||
echo "set(CMAKE_EXPORT_COMPILE_COMMANDS ON)" >> $cmake_config |
||||
echo "" >> $cmake_config |
||||
echo "if(EXISTS \"\${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json\")" >> $cmake_config |
||||
echo " execute_process(COMMAND \${CMAKE_COMMAND} -E copy_if_different" >> $cmake_config |
||||
echo " \${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json" >> $cmake_config |
||||
echo " \${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json" >> $cmake_config |
||||
echo " )" >> $cmake_config |
||||
echo "endif()" >> $cmake_config |
||||
echo "#-------- END COMPILE_COMMANDS.JSON SECTION --------#" >> $cmake_config |
||||
echo "" >> $cmake_config |
||||
echo "" >> $cmake_config |
||||
echo "file(GLOB SOURCE \${PROJECT_SOURCE_DIR}/src/*.c)" >> $cmake_config |
||||
echo "file(GLOB INCLUDE \${PROJECT_SOURCE_DIR}/include/*.h)" >> $cmake_config |
||||
echo "" >> $cmake_config |
||||
echo "" >> $cmake_config |
||||
echo "include_directories(\${PROJECT_SOURCE_DIR}/include)" >> $cmake_config |
||||
echo "" >> $cmake_config |
||||
echo "" >> $cmake_config |
||||
echo "# Controls debug printing based on the compiled binary mode - check with #ifdef DEBUG_BUILD" >> $cmake_config |
||||
echo "IF(CMAKE_BUILD_TYPE MATCHES DEBUG)" >> $cmake_config |
||||
echo "message(\"-- Configuring debug build...\")" >> $cmake_config |
||||
echo "add_compile_definitions(DEBUG_BUILD)" >> $cmake_config |
||||
echo "ENDIF(CMAKE_BUILD_TYPE MATCHES DEBUG)" >> $cmake_config |
||||
echo "" >> $cmake_config |
||||
echo "add_executable(\${PROJECT_NAME} \${SOURCE} \${INCLUDE})" >> $cmake_config |
||||
|
||||
|
||||
echo "Copying .clang-format..." |
||||
cp $script_dir/cgen_etc/clang_format_template $name/.clang-format |
||||
|
||||
echo "Copying .gitignore..." |
||||
cp $script_dir/cgen_etc/gitignore_template $name/.gitignore |
||||
|
||||
sample_file=$name/src/main.c |
||||
|
||||
echo "#include <stdio.h>" >> $sample_file |
||||
echo "" >> $sample_file |
||||
echo "" >> $sample_file |
||||
echo "int main(int argc, char **argv)" >> $sample_file |
||||
echo "{" >> $sample_file |
||||
echo " printf(\"Hello, world!\\n\");" >> $sample_file |
||||
echo " return 0;" >> $sample_file |
||||
echo "}" >> $sample_file |
||||
echo "" >> $sample_file |
||||
|
||||
git --version 2>&1 >/dev/null |
||||
GIT_IS_AVAILABLE=$? |
||||
|
||||
if [ $GIT_IS_AVAILABLE -eq 0 ] |
||||
then |
||||
git init $name |
||||
fi |
||||
|
||||
echo "Created project $name." |
@ -0,0 +1,16 @@
|
||||
AlignAfterOpenBracket: Align |
||||
AlignConsecutiveMacros: 'true' |
||||
AlignConsecutiveAssignments: 'true' |
||||
AlignConsecutiveDeclarations: 'true' |
||||
AlignTrailingComments: 'true' |
||||
BreakBeforeBraces: Allman |
||||
IndentCaseLabels: 'true' |
||||
IndentWidth: '4' |
||||
Language: Cpp |
||||
PointerAlignment: Right |
||||
SortIncludes: 'true' |
||||
SpaceBeforeParens: ControlStatements |
||||
SpaceBeforeRangeBasedForLoopColon: 'true' |
||||
SpaceInEmptyParentheses: 'false' |
||||
UseTab: Never |
||||
ColumnLimit: 80 |
@ -0,0 +1,97 @@
|
||||
# Prerequisites |
||||
*.d |
||||
|
||||
# Object files |
||||
*.o |
||||
*.ko |
||||
*.obj |
||||
*.elf |
||||
|
||||
# Linker output |
||||
*.ilk |
||||
*.map |
||||
*.exp |
||||
|
||||
# Precompiled Headers |
||||
*.gch |
||||
*.pch |
||||
|
||||
# Libraries |
||||
*.lib |
||||
*.a |
||||
*.la |
||||
*.lo |
||||
|
||||
# Shared objects (inc. Windows DLLs) |
||||
*.dll |
||||
*.so |
||||
*.so.* |
||||
*.dylib |
||||
|
||||
# Executables |
||||
*.exe |
||||
*.out |
||||
*.app |
||||
*.i*86 |
||||
*.x86_64 |
||||
*.hex |
||||
|
||||
# Debug files |
||||
*.dSYM/ |
||||
*.su |
||||
*.idb |
||||
*.pdb |
||||
|
||||
# Kernel Module Compile Results |
||||
*.mod* |
||||
*.cmd |
||||
.tmp_versions/ |
||||
modules.order |
||||
Module.symvers |
||||
Mkfile.old |
||||
dkms.conf |
||||
|
||||
# VSCode |
||||
|
||||
.vscode/* |
||||
!.vscode/settings.json |
||||
!.vscode/tasks.json |
||||
!.vscode/launch.json |
||||
!.vscode/extensions.json |
||||
*.code-workspace |
||||
|
||||
# Vim |
||||
|
||||
# Swap |
||||
[._]*.s[a-v][a-z] |
||||
!*.svg # comment out if you don't need vector files |
||||
[._]*.sw[a-p] |
||||
[._]s[a-rt-v][a-z] |
||||
[._]ss[a-gi-z] |
||||
[._]sw[a-p] |
||||
|
||||
# Session |
||||
Session.vim |
||||
Sessionx.vim |
||||
|
||||
# Temporary |
||||
.netrwhist |
||||
*~ |
||||
# Auto-generated tag files |
||||
tags |
||||
# Persistent undo |
||||
[._]*.un~ |
||||
|
||||
# CMake |
||||
|
||||
CMakeLists.txt.user |
||||
CMakeCache.txt |
||||
CMakeFiles |
||||
CMakeScripts |
||||
Testing |
||||
Makefile |
||||
cmake_install.cmake |
||||
install_manifest.txt |
||||
compile_commands.json |
||||
CTestTestfile.cmake |
||||
_deps |
@ -0,0 +1,108 @@
|
||||
#!/bin/zsh |
||||
|
||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then |
||||
symlink_dir=$(cd "$( dirname "`readlink -f ${(%):-%N}`" )" && pwd) |
||||
else |
||||
# OS X is not a fan of `readlink -f` |
||||
symlink_dir=$(cd "$( dirname "`readlink ${(%):-%N}`" )" && pwd) |
||||
fi |
||||
|
||||
# Store private information (exports, keys, etc) in .bash_private. |
||||
if [[ -f $HOME/.bash_private ]]; then |
||||
source $HOME/.bash_private |
||||
fi |
||||
|
||||
# Or alternatively .private... |
||||
if [[ -f $HOME/.private ]]; then |
||||
source $HOME/.private |
||||
fi |
||||
|
||||
# Or alternatively .zsh_private... |
||||
if [[ -f $HOME/.zsh_private ]]; then |
||||
source $HOME/.zsh_private |
||||
fi |
||||
|
||||
if [ -f $HOME/.inputrc ]; then |
||||
source $HOME/.inputrc |
||||
fi |
||||
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then |
||||
if [ -f $HOME/.macrc ]; then |
||||
source $HOME/.macrc |
||||
fi |
||||
fi |
||||
|
||||
# Set up projects and gopath folder properly for the export in the export section. |
||||
|
||||
if [[ ! -d $HOME/projects ]]; then |
||||
echo "Making $HOME/projects" |
||||
mkdir -p $HOME/projects |
||||
fi |
||||
|
||||
if [[ -x go ]]; then |
||||
echo "Making $HOME/.go" |
||||
mkdir -p $HOME/.go |
||||
fi |
||||
|
||||
|
||||
# Install zsh completion in ~/.zsh if it doesn't exist |
||||
if [[ ! -d $HOME/.zsh ]]; then |
||||
echo "Installing zsh git completion scripts" |
||||
mkdir -p $HOME/.zsh |
||||
pushd |
||||
|
||||
cd $HOME/.zsh |
||||
|
||||
curl -o git-completion.bash https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash |
||||
curl -o _git https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.zsh |
||||
|
||||
popd |
||||
fi |
||||
|
||||
autoload -U is-at-least |
||||
|
||||
# Install zsh-syntax-highlighting if it doesn't exist |
||||
if is-at-least 4.3.11; then |
||||
if [[ ! -d $HOME/.zsh/zsh-syntax-highlighting ]]; then |
||||
echo "Installing zsh syntax highlighting" |
||||
pushd |
||||
|
||||
cd $HOME/.zsh |
||||
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git |
||||
|
||||
popd |
||||
fi |
||||
else |
||||
echo "ZSH syntax highlighting requires ZSH >= 4.3.11 (current: $ZSH_VERSION)." |
||||
fi |
||||
|
||||
zstyle ':completion:*:*:git:*' script $HOME/.zsh/git-completion.bash |
||||
fpath=(~/.zsh $fpath) |
||||
|
||||
autoload -Uz compinit && compinit |
||||
|
||||
|
||||
# Pull in other configurations |
||||
source $symlink_dir/aliases.zsh |
||||
source $symlink_dir/functions.zsh |
||||
source $symlink_dir/exports.zsh |
||||
source $symlink_dir/initializations.zsh |
||||
source $symlink_dir/ps1.zsh |
||||
source $symlink_dir/keybinds.zsh |
||||
|
||||
# ZSH syntax highlighting must be sourced last |
||||
source $HOME/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh |
||||
|
||||
# Created by `userpath` on 2022-09-05 23:32:41 |
||||
export PATH="$PATH:$HOME/.local/bin" |
||||
|
||||
# ghcup config - Haskell |
||||
[ -f "/home/taylor/.ghcup/env" ] && source "/home/taylor/.ghcup/env" # ghcup-env |
||||
|
||||
# Ocaml |
||||
test -r $HOME/.opam/opam-init/init.sh && . $HOME/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true |
||||
|
||||
# Rust |
||||
if [ -f "$HOME/.cargo/env" ]; then |
||||
. "$HOME/.cargo/env" |
||||
fi |
Loading…
Reference in new issue