From 747b24bc75101c2bac3421ee24c662bc11e67f39 Mon Sep 17 00:00:00 2001 From: Max Richter Date: Sat, 7 Nov 2020 14:03:30 +0100 Subject: [PATCH] Init --- .bashrc | 117 +++++++++++ .dircolors | 484 +++++++++++++++++++++++++++++++++++++++++++ .p10k.zsh | 192 +++++++++++++++++ .zshrc | 238 +++++++++++++++++++++ bash_aliases | 32 +++ install/oh-my-zsh.sh | 1 + install/p10k.sh | 1 + setup.sh | 48 +++++ zsh/functions.zsh | 1 + zsh/y.zsh | 17 ++ 10 files changed, 1131 insertions(+) create mode 100644 .bashrc create mode 100644 .dircolors create mode 100644 .p10k.zsh create mode 100644 .zshrc create mode 100644 bash_aliases create mode 100644 install/oh-my-zsh.sh create mode 100644 install/p10k.sh create mode 100755 setup.sh create mode 100644 zsh/functions.zsh create mode 100644 zsh/y.zsh diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..09500f5 --- /dev/null +++ b/.bashrc @@ -0,0 +1,117 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color|*-256color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +#force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + #alias grep='grep --color=auto' + #alias fgrep='fgrep --color=auto' + #alias egrep='egrep --color=auto' +fi + +# colored GCC warnings and errors +#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# some more ls aliases +#alias ll='ls -l' +#alias la='ls -A' +#alias l='ls -CF' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi + +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion diff --git a/.dircolors b/.dircolors new file mode 100644 index 0000000..4027c90 --- /dev/null +++ b/.dircolors @@ -0,0 +1,484 @@ +# Exact Solarized Dark color theme for the color GNU ls utility. +# Designed for dircolors (GNU coreutils) 5.97 +# +# This simple theme was simultaneously designed for these terminal color schemes: +# - Solarized dark (best) +# - Solarized light +# - default dark +# - default light +# with a slight optimization for Solarized Dark. +# +# How the colors were selected: +# - Terminal emulators often have an option typically enabled by default that makes +# bold a different color. It is important to leave this option enabled so that +# you can access the entire 16-color Solarized palette, and not just 8 colors. +# - We favor universality over a greater number of colors. So we limit the number +# of colors so that this theme will work out of the box in all terminals, +# Solarized or not, dark or light. +# - We choose to have the following category of files: +# NORMAL & FILE, DIR, LINK, EXEC and +# editable text including source, unimportant text, binary docs & multimedia source +# files, viewable multimedia, archived/compressed, and unimportant non-text +# - For uniqueness, we stay away from the Solarized foreground colors are -- either +# base00 (brightyellow) or base0 (brightblue). However, they can be used if +# you know what the bg/fg colors of your terminal are, in order to optimize the display. +# - 3 different options are provided: universal, solarized dark, and solarized light. +# The only difference between the universal scheme and one that's optimized for +# dark/light is the color of "unimportant" files, which should blend more with the +# background +# - We note that blue is the hardest color to see on dark bg and yellow is the hardest +# color to see on light bg (with blue being particularly bad). So we choose yellow +# for multimedia files which are usually accessed in a GUI folder browser anyway. +# And blue is kept for custom use of this scheme's user. +# - See table below to see the assignments. + + +# Installation instructions: +# This file goes in the /etc directory, and must be world readable. +# You can copy this file to .dir_colors in your $HOME directory to override +# the system defaults. + +# COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not +# pipes. 'all' adds color characters to all output. 'none' shuts colorization +# off. +COLOR tty + +# Below, there should be one TERM entry for each termtype that is colorizable +TERM alacritty +TERM ansi +TERM color_xterm +TERM color-xterm +TERM con132x25 +TERM con132x30 +TERM con132x43 +TERM con132x60 +TERM con80x25 +TERM con80x28 +TERM con80x30 +TERM con80x43 +TERM con80x50 +TERM con80x60 +TERM cons25 +TERM console +TERM cygwin +TERM dtterm +TERM dvtm +TERM dvtm-256color +TERM Eterm +TERM eterm-color +TERM fbterm +TERM gnome +TERM gnome-256color +TERM jfbterm +TERM konsole +TERM konsole-256color +TERM kterm +TERM linux +TERM linux-c +TERM mach-color +TERM mlterm +TERM nxterm +TERM putty +TERM putty-256color +TERM rxvt +TERM rxvt-256color +TERM rxvt-cygwin +TERM rxvt-cygwin-native +TERM rxvt-unicode +TERM rxvt-unicode256 +TERM rxvt-unicode-256color +TERM screen +TERM screen-16color +TERM screen-16color-bce +TERM screen-16color-s +TERM screen-16color-bce-s +TERM screen-256color +TERM screen-256color-bce +TERM screen-256color-s +TERM screen-256color-bce-s +TERM screen-256color-italic +TERM screen-bce +TERM screen-w +TERM screen.linux +TERM screen.xterm-256color +TERM screen.xterm-new +TERM st +TERM st-meta +TERM st-256color +TERM st-meta-256color +TERM tmux +TERM tmux-256color +TERM vt100 +TERM xterm +TERM xterm-new +TERM xterm-16color +TERM xterm-256color +TERM xterm-256color-italic +TERM xterm-88color +TERM xterm-color +TERM xterm-debian +TERM xterm-termite + +# EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output) +EIGHTBIT 1 + +############################################################################# +# Below are the color init strings for the basic file types. A color init +# string consists of one or more of the following numeric codes: +# +# Attribute codes: +# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed +# Text color codes: +# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white +# Background color codes: +# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white +# +# NOTES: +# - See http://www.oreilly.com/catalog/wdnut/excerpt/color_names.html +# - Color combinations +# ANSI Color code Solarized Notes Universal SolDark SolLight +# ~~~~~~~~~~~~~~~ ~~~~~~~~~ ~~~~~ ~~~~~~~~~ ~~~~~~~ ~~~~~~~~ +# 00 none NORMAL, FILE +# 30 black base02 +# 01;30 bright black base03 bg of SolDark +# 31 red red docs & mm src +# 01;31 bright red orange EXEC +# 32 green green editable text +# 01;32 bright green base01 unimportant text +# 33 yellow yellow unclear in light bg multimedia +# 01;33 bright yellow base00 fg of SolLight unimportant non-text +# 34 blue blue unclear in dark bg user customized +# 01;34 bright blue base0 fg in SolDark unimportant text +# 35 magenta magenta LINK +# 01;35 bright magenta violet archive/compressed +# 36 cyan cyan DIR +# 01;36 bright cyan base1 unimportant non-text +# 37 white base2 +# 01;37 bright white base3 bg in SolLight +# 05;37;41 unclear in Putty dark + + +### By file type + +# global default +NORMAL 00 +# normal file +FILE 00 +# directory +DIR 34 +# 777 directory +OTHER_WRITABLE 34;40 +# symbolic link +LINK 35 + +# pipe, socket, block device, character device (blue bg) +FIFO 30;44 +SOCK 35;44 +DOOR 35;44 # Solaris 2.5 and later +BLK 33;44 +CHR 37;44 + + +############################################################################# +### By file attributes + +# Orphaned symlinks (blinking white on red) +# Blink may or may not work (works on iTerm dark or light, and Putty dark) +ORPHAN 05;37;41 +# ... and the files that orphaned symlinks point to (blinking white on red) +MISSING 05;37;41 + +# files with execute permission +EXEC 01;31 # Unix +.cmd 01;31 # Win +.exe 01;31 # Win +.com 01;31 # Win +.bat 01;31 # Win +.reg 01;31 # Win +.app 01;31 # OSX + +############################################################################# +### By extension + +# List any file extensions like '.gz' or '.tar' that you would like ls +# to colorize below. Put the extension, a space, and the color init string. +# (and any comments you want to add after a '#') + +### Text formats + +# Text that we can edit with a regular editor +.txt 32 +.org 32 +.md 32 +.mkd 32 + +# Source text +.h 32 +.hpp 32 +.c 32 +.C 32 +.cc 32 +.cpp 32 +.cxx 32 +.objc 32 +.cl 32 +.sh 32 +.bash 32 +.csh 32 +.zsh 32 +.el 32 +.vim 32 +.java 32 +.pl 32 +.pm 32 +.py 32 +.rb 32 +.hs 32 +.php 32 +.htm 32 +.html 32 +.shtml 32 +.erb 32 +.haml 32 +.xml 32 +.rdf 32 +.css 32 +.sass 32 +.scss 32 +.less 32 +.js 32 +.coffee 32 +.man 32 +.0 32 +.1 32 +.2 32 +.3 32 +.4 32 +.5 32 +.6 32 +.7 32 +.8 32 +.9 32 +.l 32 +.n 32 +.p 32 +.pod 32 +.tex 32 +.go 32 +.sql 32 +.csv 32 +.sv 32 +.svh 32 +.v 32 +.vh 32 +.vhd 32 + +### Multimedia formats + +# Image +.bmp 33 +.cgm 33 +.dl 33 +.dvi 33 +.emf 33 +.eps 33 +.gif 33 +.jpeg 33 +.jpg 33 +.JPG 33 +.mng 33 +.pbm 33 +.pcx 33 +.pdf 33 +.pgm 33 +.png 33 +.PNG 33 +.ppm 33 +.pps 33 +.ppsx 33 +.ps 33 +.svg 33 +.svgz 33 +.tga 33 +.tif 33 +.tiff 33 +.xbm 33 +.xcf 33 +.xpm 33 +.xwd 33 +.xwd 33 +.yuv 33 +.nef 33 # Nikon RAW format +.NEF 33 + +# Audio +.aac 33 +.au 33 +.flac 33 +.m4a 33 +.mid 33 +.midi 33 +.mka 33 +.mp3 33 +.mpa 33 +.mpeg 33 +.mpg 33 +.ogg 33 +.opus 33 +.ra 33 +.wav 33 + +# Video +.anx 33 +.asf 33 +.avi 33 +.axv 33 +.flc 33 +.fli 33 +.flv 33 +.gl 33 +.m2v 33 +.m4v 33 +.mkv 33 +.mov 33 +.MOV 33 +.mp4 33 +.mp4v 33 +.mpeg 33 +.mpg 33 +.nuv 33 +.ogm 33 +.ogv 33 +.ogx 33 +.qt 33 +.rm 33 +.rmvb 33 +.swf 33 +.vob 33 +.webm 33 +.wmv 33 + +### Misc + +# Binary document formats and multimedia source +.doc 31 +.docx 31 +.rtf 31 +.odt 31 +.dot 31 +.dotx 31 +.ott 31 +.xls 31 +.xlsx 31 +.ods 31 +.ots 31 +.ppt 31 +.pptx 31 +.odp 31 +.otp 31 +.fla 31 +.psd 31 + +# Archives, compressed +.7z 1;35 +.apk 1;35 +.arj 1;35 +.bin 1;35 +.bz 1;35 +.bz2 1;35 +.cab 1;35 # Win +.deb 1;35 +.dmg 1;35 # OSX +.gem 1;35 +.gz 1;35 +.iso 1;35 +.jar 1;35 +.msi 1;35 # Win +.rar 1;35 +.rpm 1;35 +.tar 1;35 +.tbz 1;35 +.tbz2 1;35 +.tgz 1;35 +.tx 1;35 +.war 1;35 +.xpi 1;35 +.xz 1;35 +.z 1;35 +.Z 1;35 +.zip 1;35 +.zst 1;35 + +# For testing +.ANSI-30-black 30 +.ANSI-01;30-brblack 01;30 +.ANSI-31-red 31 +.ANSI-01;31-brred 01;31 +.ANSI-32-green 32 +.ANSI-01;32-brgreen 01;32 +.ANSI-33-yellow 33 +.ANSI-01;33-bryellow 01;33 +.ANSI-34-blue 34 +.ANSI-01;34-brblue 01;34 +.ANSI-35-magenta 35 +.ANSI-01;35-brmagenta 01;35 +.ANSI-36-cyan 36 +.ANSI-01;36-brcyan 01;36 +.ANSI-37-white 37 +.ANSI-01;37-brwhite 01;37 + +############################################################################# +# Your customizations + +# Unimportant text files +# For universal scheme, use brightgreen 01;32 +# For optimal on light bg (but too prominent on dark bg), use white 01;34 +.log 01;32 +*~ 01;32 +*# 01;32 +#.log 01;34 +#*~ 01;34 +#*# 01;34 + +# Unimportant non-text files +# For universal scheme, use brightcyan 01;36 +# For optimal on dark bg (but too prominent on light bg), change to 01;33 +#.bak 01;36 +#.BAK 01;36 +#.old 01;36 +#.OLD 01;36 +#.org_archive 01;36 +#.off 01;36 +#.OFF 01;36 +#.dist 01;36 +#.DIST 01;36 +#.orig 01;36 +#.ORIG 01;36 +#.swp 01;36 +#.swo 01;36 +#*.v 01;36 +.bak 01;33 +.BAK 01;33 +.old 01;33 +.OLD 01;33 +.org_archive 01;33 +.off 01;33 +.OFF 01;33 +.dist 01;33 +.DIST 01;33 +.orig 01;33 +.ORIG 01;33 +.swp 01;33 +.swo 01;33 +*.v 01;33 + +# The brightmagenta (Solarized: purple) color is free for you to use for your +# custom file type +.gpg 34 +.gpg 34 +.pgp 34 +.asc 34 +.3des 34 +.aes 34 +.enc 34 +.sqlite 34 \ No newline at end of file diff --git a/.p10k.zsh b/.p10k.zsh new file mode 100644 index 0000000..2bd0557 --- /dev/null +++ b/.p10k.zsh @@ -0,0 +1,192 @@ +# Generated by Powerlevel10k configuration wizard on 2020-04-07 at 18:56 CEST. +# Based on romkatv/powerlevel10k/config/p10k-pure.zsh, checksum 07465. +# Wizard options: powerline, pure, 1 line, compact, instant_prompt=verbose. +# Type `p10k configure` to generate another config. +# +# Config file for Powerlevel10k with the style of Pure (https://github.com/sindresorhus/pure). +# +# Differences from Pure: +# +# - Git: +# - `@c4d3ec2c` instead of something like `v1.4.0~11` when in detached HEAD state. +# - No automatic `git fetch` (the same as in Pure with `PURE_GIT_PULL=0`). +# +# Apart from the differences listed above, the replication of Pure prompt is exact. This includes +# even the questionable parts. For example, just like in Pure, there is no indication of Git status +# being stale; prompt symbol is the same in command, visual and overwrite vi modes; when prompt +# doesn't fit on one line, it wraps around with no attempt to shorten it. +# +# If you like the general style of Pure but not particularly attached to all its quirks, type +# `p10k configure` and pick "Lean" style. This will give you slick minimalist prompt while taking +# advantage of Powerlevel10k features that aren't present in Pure. + +# Temporarily change options. +'builtin' 'local' '-a' 'p10k_config_opts' +[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') +[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') +[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') +'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' + +() { + emulate -L zsh + + # Unset all configuration options. + unset -m 'POWERLEVEL9K_*' + + # Zsh >= 5.1 is required. + autoload -Uz is-at-least && is-at-least 5.1 || return + + # Prompt colors. + local grey='242' + local red='1' + local yellow='3' + local blue='4' + local magenta='5' + local cyan='6' + local white='7' + + # Left prompt segments. + typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( + context # user@host + dir # current directory + vcs # git status + command_execution_time # previous command duration + virtualenv # python virtual environment + prompt_char # prompt symbol + ) + + # Right prompt segments. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=( + # command_execution_time # previous command duration + # virtualenv # python virtual environment + # context # user@host + # time # current time + ) + + # Basic style options that define the overall prompt look. + typeset -g POWERLEVEL9K_BACKGROUND= # transparent background + typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # no surrounding whitespace + typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # separate segments with a space + typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR= # no end-of-line symbol + typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION= # no segment icons + + # Add an empty line before each prompt except the first. This doesn't emulate the bug + # in Pure that makes prompt drift down whenever you use the Alt-C binding from fzf or similar. + typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=false + + # Magenta prompt symbol if the last command succeeded. + typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS}_FOREGROUND=$magenta + # Red prompt symbol if the last command failed. + typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS}_FOREGROUND=$red + # Default prompt symbol. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='❯' + # Prompt symbol in command vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❮' + # Prompt symbol in visual vi mode is the same as in command mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='❮' + # Prompt symbol in overwrite vi mode is the same as in command mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=false + + # Grey Python Virtual Environment. + typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=$grey + # Don't show Python version. + typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false + typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER= + + # Blue current directory. + typeset -g POWERLEVEL9K_DIR_FOREGROUND=$blue + + # Context format when root: user@host. The first part white, the rest grey. + typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE="%F{$white}%n%f%F{$grey}@%m%f" + # Context format when not root: user@host. The whole thing grey. + typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE="%F{$grey}%n@%m%f" + # Don't show context unless root or in SSH. + typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_CONTENT_EXPANSION= + + # Show previous command duration only if it's >= 5s. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=5 + # Don't show fractional seconds. Thus, 7s rather than 7.3s. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 + # Duration format: 1d 2h 3m 4s. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s' + # Yellow previous command duration. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=$yellow + + # Grey Git prompt. This makes stale prompts indistinguishable from up-to-date ones. + typeset -g POWERLEVEL9K_VCS_FOREGROUND=$grey + + # Disable async loading indicator to make directories that aren't Git repositories + # indistinguishable from large Git repositories without known state. + typeset -g POWERLEVEL9K_VCS_LOADING_TEXT= + + # Don't wait for Git status even for a millisecond, so that prompt always updates + # asynchronously when Git state changes. + typeset -g POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS=0 + + # Cyan ahead/behind arrows. + typeset -g POWERLEVEL9K_VCS_{INCOMING,OUTGOING}_CHANGESFORMAT_FOREGROUND=$cyan + # Don't show remote branch, current tag or stashes. + typeset -g POWERLEVEL9K_VCS_GIT_HOOKS=(vcs-detect-changes git-untracked git-aheadbehind) + # Don't show the branch icon. + typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= + # When in detached HEAD state, show @commit where branch normally goes. + typeset -g POWERLEVEL9K_VCS_COMMIT_ICON='@' + # Don't show staged, unstaged, untracked indicators. + typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED}_ICON= + # Show '*' when there are staged, unstaged or untracked files. + typeset -g POWERLEVEL9K_VCS_DIRTY_ICON='*' + # Show '⇣' if local branch is behind remote. + typeset -g POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON=':⇣' + # Show '⇡' if local branch is ahead of remote. + typeset -g POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON=':⇡' + # Don't show the number of commits next to the ahead/behind arrows. + typeset -g POWERLEVEL9K_VCS_{COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=1 + # Remove space between '⇣' and '⇡' and all trailing spaces. + typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${${${P9K_CONTENT/⇣* :⇡/⇣⇡}// }//:/ }' + + # Grey current time. + typeset -g POWERLEVEL9K_TIME_FOREGROUND=$grey + # Format for the current time: 09:51:02. See `man 3 strftime`. + typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}' + # If set to true, time will update when you hit enter. This way prompts for the past + # commands will contain the start times of their commands rather than the end times of + # their preceding commands. + typeset -g POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=false + + # Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt + # when accepting a command line. Supported values: + # + # - off: Don't change prompt when accepting a command line. + # - always: Trim down prompt when accepting a command line. + # - same-dir: Trim down prompt when accepting a command line unless this is the first command + # typed after changing current working directory. + typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=off + + # Instant prompt mode. + # + # - off: Disable instant prompt. Choose this if you've tried instant prompt and found + # it incompatible with your zsh configuration files. + # - quiet: Enable instant prompt and don't print warnings when detecting console output + # during zsh initialization. Choose this if you've read and understood + # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. + # - verbose: Enable instant prompt and print a warning when detecting console output during + # zsh initialization. Choose this if you've never tried instant prompt, haven't + # seen the warning, or if you are unsure what this all means. + typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose + + # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized. + # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload + # can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you + # really need it. + typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true + + # If p10k is already loaded, reload configuration. + # This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true. + (( ! $+functions[p10k] )) || p10k reload +} + +# Tell `p10k configure` which file it should overwrite. +typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a} + +(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} +'builtin' 'unset' 'p10k_config_opts' \ No newline at end of file diff --git a/.zshrc b/.zshrc new file mode 100644 index 0000000..a6bf087 --- /dev/null +++ b/.zshrc @@ -0,0 +1,238 @@ +# INITILIZATION ## + +# p10k +if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then + source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" +fi +ZSH_THEME="powerlevel10k/powerlevel10k" + + +## for vxcsrv on wsl +export GOPATH="/home/jim/Sync" + +plugins=( + git + npm + zsh-autosuggestions +) + +eval `dircolors ~/.dircolors` + +# Load oh my zsh +export ZSH=~/.oh-my-zsh +source $ZSH/oh-my-zsh.sh + +## FUNCTIONS ## + +# Helps navigating Sync directory +function fx(){ + + cd /home/jim/Sync/ + + if [ "$1" = "o" ]; then + + cd $2 + + code-insiders . + + if [ "$3" = "live" ]; then + command live-server + fi + + elif [ "$1" = "w" ]; then + + cd /Library/WebServer/Documents/ + + elif [ "$1" = "s" ]; then + cd $2 + fi + +} + +# Helps navigating wordpress directory +function wp(){ + + first_dir=${1%/*} + second_dir=${1#*/} + + if [ $first_dir = $second_dir ]; then + second_dir="" + fi + + if [ $first_dir = "plugins" ]; then + cd "wp-content/plugins" + elif [ $first_dir = "themes" ]; then + cd "wp-content/themes" + fi + + if [ $second_dir != "" ]; then + + fi + + +} + +# Helps navigating COCO directory +function co(){ + + cd ~/COCO + + openCode=false + + if [ "$1" = "o" ]; then + 1=$2; + openCode=true + fi + + first_dir=${1%/*}; + second_dir=${1#*/}; + + if [ -z $first_dir ]; then + first_dir="" + fi + + if [ -z $second_dir ]; then + second_dir="" + fi + + if [ ! -v $first_dir ]; then + coco_dir=$(ls | grep $first_dir | head -n 1) + + if [ -z "$coco_dir" ]; then + + echo "No directory exists for course $first_dir. Create a new one? (y/n)" + + read createDir + + if [ "$createDir" = "y" ]; then + echo "What should the name be?" + read dirName + dirName=$first_dir"_$dirName" + mkdir $dirName + cd $dirName + echo "Created $dirName" + fi + + + else + + cd $coco_dir + amount=$(find ./* -maxdepth 0 -type d | wc -l) + + if [ "$amount" = "1" ]; then + dir=$(find ./* -maxdepth 0 -type d) + cd $dir + fi + + fi + + if [ $second_dir != $first_dir ]; then + cd $second_dir + fi + + fi + + if [ $openCode = true ]; then + code-insiders . + fi + + } + + + + + +# Helps with starting stuff +function start(){ + + serviceName=$1; + + if [ $serviceName = "docker" ]; then + + dockerStatus="$(service docker status)" + + if [ "${dockerStatus#*"not running"}" != "$dockerStatus" ]; then + echo "➜ starting docker" + echo "➜ $(sudo service docker start)" + fi + + sleep 0.5 + + elif [ $serviceName = "mongo" ]; then + + start docker + + start container mongo + + elif [ $serviceName = "dc" ]; then + + start docker + + echo "➜ starting docker-compose" + + dc up -d + + elif [ $serviceName = "spring" ]; then + + start mongo + + echo "➜ starting spring-boot" + + mvn spring-boot:run + + elif [ $serviceName = "container" ]; then + + containerName=$2; + + containerInfo="[port:$(docker port $containerName) volume:$(docker inspect -f '{{index (.HostConfig.Binds) 0}}' $containerName)]" + + containerIsRunning="$(docker inspect -f '{{.State.Running}}' $containerName 2>/dev/null)" + + containerStatus="$(docker inspect -f '{{.State.Status}}' $containerName 2>/dev/null)" + + if [ $containerIsRunning = "true" ]; then + echo "➜ $containerName already running $containerInfo" + elif [ $containerStatus = "exited" ]; then + echo "➜ running $containerName $containerInfo" + echo "➜ id:$(sudo docker start $containerName)" + else + echo "➜ container $containerName $containerInfo doesnt exist" + fi + + elif [ $serviceName = "dc" ]; then + + start docker + + echo "➜ starting docker-compose" + + dc up -d + + fi + +} + + + +## LOADING PROGRAMS + +export PATH="$PATH:/usr/local/sbin" +export PATH="$PATH:/opt/local/bin" +export PATH="$PATH:/usr/local" +export PATH="$PATH:/usr/local/vcpkg" +export PATH="$PATH:/usr/local/arduino" +export PATH="$PATH:/usr/local/processing" +export PATH="$PATH:$HOME/.yarn/bin" +export PATH="$PATH:$HOME/.local/bin" +export PATH="$PATH:$HOME/go/bin" + +eval "$(direnv hook zsh)" + +#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!! +export SDKMAN_DIR="/home/jim/.sdkman" +[[ -s "/home/jim/.sdkman/bin/sdkman-init.sh" ]] && source "/home/jim/.sdkman/bin/sdkman-init.sh" + +# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. +[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh + +# Go version manager +[[ -s "/home/jim/.gvm/scripts/gvm" ]] && source "/home/jim/.gvm/scripts/gvm" \ No newline at end of file diff --git a/bash_aliases b/bash_aliases new file mode 100644 index 0000000..2909ab6 --- /dev/null +++ b/bash_aliases @@ -0,0 +1,32 @@ +## ALIASIES ## +alias -s {yml,yaml,ts,json,js,vim,rc}=nvim + +alias ci="code-insiders" +alias yoink="curl" + +alias pls='sudo -E env "PATH=$PATH"' + +alias lc='colorls -lA --s' + +alias zshc="vim ~/.zshrc" +alias zshu="source ~/.zshrc" + +alias nano="nvim" + +alias ww="webpack -w" + +alias ys="yarn start" +alias yd="yarn dev" +alias yi="yarn install" +alias ya="yarn add" + +alias gs="git status" +alias gaa="git add ." +alias gpm="git push origin master" +alias gcm="git commit -m " +alias czi="commitizen init cz-conventional-changelog --yarn --dev --exact" +alias cz="git-cz" + +alias lt="tree -L 2 --filelimit 150 --dirsfirst" + +alias dc="docker-compose" \ No newline at end of file diff --git a/install/oh-my-zsh.sh b/install/oh-my-zsh.sh new file mode 100644 index 0000000..772fbb7 --- /dev/null +++ b/install/oh-my-zsh.sh @@ -0,0 +1 @@ +sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" \ No newline at end of file diff --git a/install/p10k.sh b/install/p10k.sh new file mode 100644 index 0000000..abd894a --- /dev/null +++ b/install/p10k.sh @@ -0,0 +1 @@ +git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k \ No newline at end of file diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..976116e --- /dev/null +++ b/setup.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +function isInstalled(){ + if [ "$(which $1)" != "" ]; then + return 0; + fi + return 1; +} + +function installOptional(){ + echo "install optional '$*'" + + # Check if any of the listed programs are installed + # if not install the first one; + for prog in "$@" + do + if isInstalled $prog; then + echo "$prog is installed"; + break + fi + done + + install $1; + +} + +function install { + # Check if program is already installed + if isInstalled $1; then + echo "$1 is already installed" + else + echo "installing $1" + apt-get install $1 + fi +} + + +#Prerequesits +echo "-- Installing prerequisites --" +install git +install curl + +echo "-- Installing Oh-My-Zsh --" +install zsh +./install/oh-my-szh.sh +./install/p10k.sh + +install nope \ No newline at end of file diff --git a/zsh/functions.zsh b/zsh/functions.zsh new file mode 100644 index 0000000..a65d678 --- /dev/null +++ b/zsh/functions.zsh @@ -0,0 +1 @@ +source ./y.sh; \ No newline at end of file diff --git a/zsh/y.zsh b/zsh/y.zsh new file mode 100644 index 0000000..95f4d08 --- /dev/null +++ b/zsh/y.zsh @@ -0,0 +1,17 @@ +function y(){ + word=$(echo "$1" | fold -w 1) + for char in $(echo $word) + do + if [ $char = "i" ]; then + yarn install + elif [ $char = "d" ]; then + yarn dev + elif [ $char = "b" ]; then + yarn build + elif [ $char = "a" ]; then + yarn add + elif [ $char = "u" ]; then + yarn upgrade + fi + done +} \ No newline at end of file