Last active
December 6, 2024 01:49
-
-
Save swyxio/7fa1009e460ecb818d5e6d9ca4616a05 to your computer and use it in GitHub Desktop.
my dotfiles - more info here https://www.swyx.io/new-mac-setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.DS_Store | |
._.DS_Store | |
**/.DS_Store | |
**/._.DS_Store | |
.vscode | |
.idea | |
Thumbs.db | |
# used to need to run git config --global core.excludesfile ~/.gitignore_global to set this but apparently no longer needed https://x.com/bate5a55/status/1840594630972191118 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set autoindent | |
set indentexpr=off | |
set expandtab | |
set tabstop=4 | |
set sw=4 | |
set textwidth=80 | |
set nohls | |
set noshowmatch | |
syntax enable | |
setlocal spell spelllang=en_us | |
set nospell | |
set background=dark | |
autocmd VimEnter * set vb t_vb= | |
set modeline | |
set nojoinspaces " pesky 2-spaces after the period thing | |
set shortmess=AITstW " I hate: naggy dialogs, intros, long messages | |
set noshowcmd | |
set nowritebackup | |
set noswapfile | |
set nobackup | |
" don't delete whitespace-only lines leaving insert mode: | |
inoremap <CR> x<BS><CR>x<BS> | |
inoremap <up> x<BS><up> | |
inoremap <down> x<BS><down> | |
nnoremap o ox<BS> | |
nnoremap O Ox<BS> | |
" for fzf https://github.com/junegunn/fzf | |
set rtp+=/usr/local/opt/fzf | |
" fuck everything about the 'Press ENTER' message: | |
set showcmd | |
set shortmess=at | |
" 2-space indent for html and json files | |
autocmd BufRead,BufNewFile *.json,*.html,*.css,*.svg set sw=2 tabstop=2 | |
autocmd BufRead,BufNewFile Makefile,makefile,*Makefile,*makefile set noexpandtab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you come from bash you might have to change your $PATH. | |
# export PATH=$HOME/bin:/usr/local/bin:$PATH | |
# export PATH="/Users/swyx/.pyenv/versions/3.11.3/lib/python3.11/site-packages:$PATH" | |
#Path to your oh-my-zsh installation. | |
export ZSH=/Users/swyx/.oh-my-zsh | |
# to stop silly homebrew autoupdate | |
export HOMEBREW_NO_AUTO_UPDATE=1 | |
# to stop silly ohmyzsh nag https://github.com/ohmyzsh/ohmyzsh#getting-updates | |
zstyle ':omz:update' frequency 30 | |
# Set name of the theme to load. Optionally, if you set this to "random" | |
# it'll load a random theme each time that oh-my-zsh is loaded. | |
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes | |
# ZSH_THEME="robbyrussell" | |
ZSH_THEME="agnoster" | |
# ZSH_THEME="awesomepanda" | |
# Uncomment the following line to use case-sensitive completion. | |
# CASE_SENSITIVE="true" | |
# Uncomment the following line to use hyphen-insensitive completion. Case | |
# sensitive completion must be off. _ and - will be interchangeable. | |
# HYPHEN_INSENSITIVE="true" | |
# Uncomment the following line to disable bi-weekly auto-update checks. | |
# DISABLE_AUTO_UPDATE="true" | |
# Uncomment the following line to change how often to auto-update (in days). | |
# export UPDATE_ZSH_DAYS=13 | |
# Uncomment the following line to disable colors in ls. | |
# DISABLE_LS_COLORS="true" | |
# Uncomment the following line to disable auto-setting terminal title. | |
# DISABLE_AUTO_TITLE="true" | |
# Uncomment the following line to enable command auto-correction. | |
# ENABLE_CORRECTION="true" | |
# Uncomment the following line to display red dots whilst waiting for completion. | |
# COMPLETION_WAITING_DOTS="true" | |
# Uncomment the following line if you want to disable marking untracked files | |
# under VCS as dirty. This makes repository status check for large repositories | |
# much, much faster. | |
# DISABLE_UNTRACKED_FILES_DIRTY="true" | |
# Uncomment the following line if you want to change the command execution time | |
# stamp shown in the history command output. | |
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" | |
# HIST_STAMPS="mm/dd/yyyy" | |
# Would you like to use another custom folder than $ZSH/custom? | |
# ZSH_CUSTOM=/path/to/new-custom-folder | |
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) | |
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ | |
# Example format: plugins=(rails git textmate ruby lighthouse) | |
# Add wisely, as too many plugins slow down shell startup. | |
plugins=(git zsh-autosuggestions zsh-syntax-highlighting) | |
source $ZSH/oh-my-zsh.sh | |
# User configuration | |
# export MANPATH="/usr/local/man:$MANPATH" | |
# You may need to manually set your language environment | |
# export LANG=en_US.UTF-8 | |
# Preferred editor for local and remote sessions | |
# if [[ -n $SSH_CONNECTION ]]; then | |
# export EDITOR='vim' | |
# else | |
# export EDITOR='mvim' | |
# fi | |
# Compilation flags | |
# export ARCHFLAGS="-arch x86_64" | |
# ssh | |
# export SSH_KEY_PATH="~/.ssh/rsa_id" | |
# Set personal aliases, overriding those provided by oh-my-zsh libs, | |
# plugins, and themes. Aliases can be placed here, though oh-my-zsh | |
# users are encouraged to define aliases within the ZSH_CUSTOM folder. | |
# For a full list of active aliases, run `alias`. | |
# | |
# Example aliases | |
# alias zshconfig="mate ~/.zshrc" | |
# alias ohmyzsh="mate ~/.oh-my-zsh" | |
alias mv="mv -iv" | |
alias cp="cp -iv" | |
alias lsd="ls -ltr" # List files/folders by the most recently changed. | |
alias json_pretty="pbpaste | python -m json.tool | pbcopy" # https://news.ycombinator.com/item?id=36517860 | |
alias zs="source ~/.zshrc" | |
alias zshrc="vi ~/.zshrc" | |
alias gclone="git clone --depth 1 " | |
alias gpom="git push origin main" | |
alias gpo="git push origin " | |
alias gset="git remote set-url" | |
alias gs="git status" | |
alias gadmit="git add . && git commit -m" | |
alias gc="git checkout" | |
alias gcb="git checkout -b " | |
alias gupdatefork="git fetch upstream && git checkout master && git rebase | |
upstream/master" | |
alias gcm="git checkout main 2> /dev/null || git checkout master" | |
alias rm=trash # move files to trash instead of instant delete. need to install trash cli | |
alias fucking=sudo | |
alias gl="git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all" | |
alias glr='gl -n 7' | |
alias git-clean-merged="git branch --merged master | grep -v 'master$' | xargs git branch -d" | |
alias git-clean-remote-merged="git branch -r --merged | grep -v master | sed 's/origin\///' | xargs -n 1 git push --delete origin" | |
# https://news.ycombinator.com/item?id=36170154 | |
alias gitsum='git log --pretty=format:"* %s" --author `git config user.email`' | |
#myself | |
alias run="npm run" | |
alias sudomongod="sudo mongod --smallfiles" | |
## yarn | |
alias yb="yarn build" | |
alias ys="yarn start" | |
# python and django | |
export PYENV_ROOT="$HOME/.pyenv" | |
export PATH="$PYENV_ROOT/bin:$PATH" | |
eval "$(pyenv init -)" | |
eval "$(pyenv virtualenv-init -)" | |
alias mkvenv="python3 -m venv env" | |
alias entervenv="source env/bin/activate" | |
alias pyarn="pip install -r requirements.txt # install all requirements" | |
alias pyfreeze="pip freeze > requirements.txt # save all requirements" | |
alias pyinit="mkvenv && env >> .gitignore" | |
function pi { | |
pip install "$1" | |
pyfreeze | |
} | |
alias djrun="python manage.py runserver" | |
alias pm="python manage.py " | |
alias py="python -m pdb -c c" # https://twitter.com/jeremyphoward/status/1756541454288396402 | |
alias ytdlmp3="youtube-dl -x --audio-format mp3 " | |
function mkcdir () | |
{ | |
mkdir -p -- "$1" && | |
cd -P -- "$1" | |
} | |
# for fzf https://github.com/junegunn/fzf | |
alias preview="fzf --preview 'bat --color \"always\" {}'" | |
alias cat='bat' | |
## add support for ctrl+o to open selected file in VS Code | |
export FZF_DEFAULT_OPTS="--bind='ctrl-o:execute(code-insiders {})+abort'" | |
eval "$(fnm env --use-on-cd)" # for fnm shell variables - make sure fnm is installed | |
. /opt/homebrew/etc/profile.d/z.sh # this is for rupa/z - make sure rupa/z is installed | |
# gdate=/usr/local/bin/gdate | |
# if [ ! -x $gdate ]; then | |
# echo "FATAL ERROR: $gdate not found." >&2 | |
# exit 1 | |
# fi | |
# preexec() { | |
# timer=$(gdate +%s.%N) | |
# } | |
# precmd() { | |
# if [ -n "$timer" ]; then | |
# now=$(gdate +%s.%N) | |
# elapsed=$(echo "$now - $timer" | bc) | |
# timer_show=$(printf "%.2f" $elapsed) | |
# echo "Execution time: ${timer_show}s" | |
# unset timer | |
# fi | |
# } | |
# https://twitter.com/wesbos/status/601426471240998912 | |
function t() { | |
tree -I '.git|node_modules|bower_components|.DS_Store' --dirsfirst --filelimit 15 -L ${1:-3} -aC $2 | |
} | |
# pnpm | |
export PNPM_HOME="/Users/swyx/Library/pnpm" | |
case ":$PATH:" in | |
*":$PNPM_HOME:"*) ;; | |
*) export PATH="$PNPM_HOME:$PATH" ;; | |
esac | |
# pnpm end | |
# bun completions | |
[ -s "/Users/swyx/.bun/_bun" ] && source "/Users/swyx/.bun/_bun" | |
# bun | |
export BUN_INSTALL="$HOME/.bun" | |
export PATH="$BUN_INSTALL/bin:$PATH" | |
# >>> conda initialize >>> | |
# !! Contents within this block are managed by 'conda init' !! | |
__conda_setup="$('/Users/swyx/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)" | |
if [ $? -eq 0 ]; then | |
eval "$__conda_setup" | |
else | |
if [ -f "/Users/swyx/miniconda3/etc/profile.d/conda.sh" ]; then | |
. "/Users/swyx/miniconda3/etc/profile.d/conda.sh" | |
else | |
export PATH="/Users/swyx/miniconda3/bin:$PATH" | |
fi | |
fi | |
unset __conda_setup | |
# <<< conda initialize <<< | |
. "$HOME/.cargo/env" | |
################################################################ | |
# https://github.com/pmarreck/dotfiles/blob/master/bin/functions/please.bash | |
# obligatory AI stuff | |
# must brew install gum as well | |
################################################################ | |
# you can also try https://x.com/pbbakkum/status/1847033065195139583 | |
# or https://github.com/simonw/llm-cmd | |
# or https://github.com/TNG/please-cli | |
################################################################ | |
# graceful dependency enforcement | |
# Usage: needs <executable> [provided by <packagename>] | |
# only redefines it here if it's not already defined | |
# >/dev/null declare -F needs || \ | |
needs() { | |
[ -v EDIT ] && unset EDIT && edit_function "${FUNCNAME[0]}" "$BASH_SOURCE" && return | |
local bin=$1 | |
shift | |
command -v "$bin" >/dev/null 2>&1 || { echo >&2 "I require $bin but it's not installed or in PATH; $*"; return 1; } | |
} | |
platform() { | |
[ -v EDIT ] && unset EDIT && edit_function "${FUNCNAME[0]}" "$BASH_SOURCE" && return | |
local unameOut | |
local machine | |
unameOut="$(uname -s)" | |
case "${unameOut}" in | |
Linux*) machine=Linux;; | |
Darwin*) machine=macOS;; | |
CYGWIN*) machine=Cygwin;; | |
MINGW*) machine=MinGW;; | |
*) machine="${unameOut}" | |
esac | |
printf "%s" "$machine" | |
} | |
_generate_curl_api_request_for_please() { | |
[ -v EDIT ] && unset EDIT && edit_function "${FUNCNAME[0]}" "$BASH_SOURCE" && return | |
needs jq | |
local request args timeout model curl | |
curl=${CURL:-curl} | |
model=${OPENAI_MODEL:-gpt-4-1106-preview} # other options: gpt-4, gpt-4-0314, gpt-4-32k, gpt-4-32k-0314, gpt-3.5-turbo, gpt-3.5-turbo-0301 | |
timeout=${OPENAI_TIMEOUT:-30} | |
args="$@" | |
args=$(printf "%b" "$args" | sed "s/'/'\\\\''/g") # This is just a narsty sed to escape single quotes. | |
# (Piping to "jq -sRr '@json'" was not working correctly, so I had to take control of the escaping myself.) | |
# printf "escaped args: %b\n" "$args" >&2 | |
# note that gpt-3.5-turbo-0301 is the very latest model as of 2021-03-01 but will only be supported for a few weeks | |
read -r -d '' request <<EOF | |
$curl https://api.openai.com/v1/chat/completions \ | |
-H "Authorization: Bearer $OPENAI_API_KEY" \ | |
-H "Content-Type: application/json" \ | |
--silent \ | |
--max-time $timeout \ | |
-d '{"model": "$model", "messages": [{"role": "user", "content": "$args"}], "temperature": 0.7}' | |
EOF | |
printf "%b" "$request" | |
} | |
# you can also try https://x.com/pbbakkum/status/1847033065195139583 | |
please() { | |
[ -v EDIT ] && unset EDIT && edit_function "${FUNCNAME[0]}" "$BASH_SOURCE" && return | |
needs curl | |
needs jq | |
needs gum from https://github.com/charmbracelet/gum | |
local request response response_parsed response_parsed_cleaned args | |
local plat=$(platform) | |
request=$(_generate_curl_api_request_for_please "What is the $plat bash command to $@? Only return the command to run itself, do not describe anything. Only use commands and executables that are common on most $plat systems. Do not quote the response and do not use markdown.") | |
# printf "request: %s\n" "$request" >&2 | |
response=$(eval "gum spin --show-output -s line --title \"Figuring out how to do this...\" -- $request") | |
# printf "response: %s\n" "$response" >&2 | |
response_parsed=$(printf "%s" "$response" | jq --raw-output '.choices[0].message.content') | |
# printf "response_parsed: %s\n" "$response_parsed" >&2 | |
if [[ "$response_parsed" == "null" || "$?" != "0" ]]; then | |
printf "Error:\n" >&2 | |
printf "%b\n" "$response" >&2 | |
printf "%b\n" "$response_parsed" | |
else | |
response_parsed_cleaned=$(printf "%s" "$response_parsed" | sed -e 's/^[\\n]\+//' -e 's/^[\n]\+//') | |
if gum confirm --affirmative="Run it" --negative="GTFO" "$response_parsed_cleaned"; then | |
printf "\e[0;33m%s\n\e[m" "$response_parsed_cleaned" >&2 | |
printf "%s" "$response_parsed_cleaned" | bash | |
else | |
printf "%s" "Aborted." | |
return 1 | |
fi | |
fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vim:ft=zsh ts=2 sw=2 sts=2 | |
# | |
# agnoster's Theme - https://gist.github.com/3712874 | |
# A Powerline-inspired theme for ZSH | |
# | |
# # README | |
# | |
# In order for this theme to render correctly, you will need a | |
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts). | |
# Make sure you have a recent version: the code points that Powerline | |
# uses changed in 2012, and older versions will display incorrectly, | |
# in confusing ways. | |
# | |
# In addition, I recommend the | |
# [Solarized theme](https://github.com/altercation/solarized/) and, if you're | |
# using it on Mac OS X, [iTerm 2](https://iterm2.com/) over Terminal.app - | |
# it has significantly better color fidelity. | |
# | |
# If using with "light" variant of the Solarized color schema, set | |
# SOLARIZED_THEME variable to "light". If you don't specify, we'll assume | |
# you're using the "dark" variant. | |
# | |
# # Goals | |
# | |
# The aim of this theme is to only show you *relevant* information. Like most | |
# prompts, it will only show git information when in a git working directory. | |
# However, it goes a step further: everything from the current user and | |
# hostname to whether the last call exited with an error to whether background | |
# jobs are running in this shell will all be displayed automatically when | |
# appropriate. | |
### Segment drawing | |
# A few utility functions to make it easy and re-usable to draw segmented prompts | |
CURRENT_BG='NONE' | |
case ${SOLARIZED_THEME:-dark} in | |
light) CURRENT_FG='white';; | |
*) CURRENT_FG='black';; | |
esac | |
# Special Powerline characters | |
() { | |
local LC_ALL="" LC_CTYPE="en_US.UTF-8" | |
# NOTE: This segment separator character is correct. In 2012, Powerline changed | |
# the code points they use for their special characters. This is the new code point. | |
# If this is not working for you, you probably have an old version of the | |
# Powerline-patched fonts installed. Download and install the new version. | |
# Do not submit PRs to change this unless you have reviewed the Powerline code point | |
# history and have new information. | |
# This is defined using a Unicode escape sequence so it is unambiguously readable, regardless of | |
# what font the user is viewing this source code in. Do not replace the | |
# escape sequence with a single literal character. | |
# Do not change this! Do not make it '\u2b80'; that is the old, wrong code point. | |
SEGMENT_SEPARATOR=$'\ue0b0' | |
} | |
# Begin a segment | |
# Takes two arguments, background and foreground. Both can be omitted, | |
# rendering default background/foreground. | |
prompt_segment() { | |
local bg fg | |
[[ -n $1 ]] && bg="%K{$1}" || bg="%k" | |
[[ -n $2 ]] && fg="%F{$2}" || fg="%f" | |
if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then | |
echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} " | |
else | |
echo -n "%{$bg%}%{$fg%} " | |
fi | |
CURRENT_BG=$1 | |
[[ -n $3 ]] && echo -n $3 | |
} | |
# End the prompt, closing any open segments | |
prompt_end() { | |
if [[ -n $CURRENT_BG ]]; then | |
echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" | |
else | |
echo -n "%{%k%}" | |
fi | |
echo -n "%{%f%}" | |
CURRENT_BG='' | |
} | |
### Prompt components | |
# Each component will draw itself, and hide itself if no information needs to be shown | |
# Context: user@hostname (who am I and where am I) | |
prompt_context() { | |
if [[ "$USERNAME" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then | |
prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m" | |
fi | |
} | |
# Git: branch/detached head, dirty status | |
prompt_git() { | |
(( $+commands[git] )) || return | |
if [[ "$(git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]]; then | |
return | |
fi | |
local PL_BRANCH_CHAR | |
() { | |
local LC_ALL="" LC_CTYPE="en_US.UTF-8" | |
PL_BRANCH_CHAR=$'\ue0a0' # | |
} | |
local ref dirty mode repo_path | |
if [[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then | |
repo_path=$(git rev-parse --git-dir 2>/dev/null) | |
dirty=$(parse_git_dirty) | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)" | |
if [[ -n $dirty ]]; then | |
prompt_segment yellow black | |
else | |
prompt_segment green $CURRENT_FG | |
fi | |
if [[ -e "${repo_path}/BISECT_LOG" ]]; then | |
mode=" <B>" | |
elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then | |
mode=" >M<" | |
elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then | |
mode=" >R>" | |
fi | |
setopt promptsubst | |
autoload -Uz vcs_info | |
zstyle ':vcs_info:*' enable git | |
zstyle ':vcs_info:*' get-revision true | |
zstyle ':vcs_info:*' check-for-changes true | |
zstyle ':vcs_info:*' stagedstr '✚' | |
zstyle ':vcs_info:*' unstagedstr '±' | |
zstyle ':vcs_info:*' formats ' %u%c' | |
zstyle ':vcs_info:*' actionformats ' %u%c' | |
vcs_info | |
echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}" | |
fi | |
} | |
prompt_bzr() { | |
(( $+commands[bzr] )) || return | |
# Test if bzr repository in directory hierarchy | |
local dir="$PWD" | |
while [[ ! -d "$dir/.bzr" ]]; do | |
[[ "$dir" = "/" ]] && return | |
dir="${dir:h}" | |
done | |
local bzr_status status_mod status_all revision | |
if bzr_status=$(bzr status 2>&1); then | |
status_mod=$(echo -n "$bzr_status" | head -n1 | grep "modified" | wc -m) | |
status_all=$(echo -n "$bzr_status" | head -n1 | wc -m) | |
revision=$(bzr log -r-1 --log-format line | cut -d: -f1) | |
if [[ $status_mod -gt 0 ]] ; then | |
prompt_segment yellow black "bzr@$revision ✚" | |
else | |
if [[ $status_all -gt 0 ]] ; then | |
prompt_segment yellow black "bzr@$revision" | |
else | |
prompt_segment green black "bzr@$revision" | |
fi | |
fi | |
fi | |
} | |
prompt_hg() { | |
(( $+commands[hg] )) || return | |
local rev st branch | |
if $(hg id >/dev/null 2>&1); then | |
if $(hg prompt >/dev/null 2>&1); then | |
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then | |
# if files are not added | |
prompt_segment red white | |
st='±' | |
elif [[ -n $(hg prompt "{status|modified}") ]]; then | |
# if any modification | |
prompt_segment yellow black | |
st='±' | |
else | |
# if working copy is clean | |
prompt_segment green $CURRENT_FG | |
fi | |
echo -n $(hg prompt "☿ {rev}@{branch}") $st | |
else | |
st="" | |
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g') | |
branch=$(hg id -b 2>/dev/null) | |
if `hg st | grep -q "^\?"`; then | |
prompt_segment red black | |
st='±' | |
elif `hg st | grep -q "^[MA]"`; then | |
prompt_segment yellow black | |
st='±' | |
else | |
prompt_segment green $CURRENT_FG | |
fi | |
echo -n "☿ $rev@$branch" $st | |
fi | |
fi | |
} | |
# Dir: current working directory | |
prompt_dir() { | |
prompt_segment cyan $CURRENT_FG '%1d' | |
# prompt_segment blue $CURRENT_FG '%~' | |
} | |
# Virtualenv: current working virtualenv | |
prompt_virtualenv() { | |
local virtualenv_path="$VIRTUAL_ENV" | |
if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then | |
prompt_segment blue black "(`basename $virtualenv_path`)" | |
fi | |
} | |
# Status: | |
# - was there an error | |
# - am I root | |
# - are there background jobs? | |
prompt_status() { | |
local -a symbols | |
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘" | |
[[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" | |
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" | |
[[ -n "$symbols" ]] && prompt_segment black default "$symbols" | |
} | |
#AWS Profile: | |
# - display current AWS_PROFILE name | |
# - displays yellow on red if profile name contains 'production' or | |
# ends in '-prod' | |
# - displays black on green otherwise | |
prompt_aws() { | |
[[ -z "$AWS_PROFILE" || "$SHOW_AWS_PROMPT" = false ]] && return | |
case "$AWS_PROFILE" in | |
*-prod|*production*) prompt_segment red yellow "AWS: $AWS_PROFILE" ;; | |
*) prompt_segment green black "AWS: $AWS_PROFILE" ;; | |
esac | |
} | |
## Main prompt | |
build_prompt() { | |
RETVAL=$? | |
prompt_status | |
prompt_virtualenv | |
prompt_aws | |
# prompt_context | |
prompt_dir | |
prompt_git | |
prompt_bzr | |
prompt_hg | |
prompt_end | |
} | |
PROMPT='%{%f%b%k%}$(build_prompt) ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"workbench.colorTheme": "Shades of Purple", | |
"terminal.integrated.fontFamily": "Meslo LG M DZ for Powerline", | |
"editor.tabSize": 2, | |
"editor.minimap.enabled": false, | |
"[typescriptreact]": { | |
"editor.defaultFormatter": "esbenp.prettier-vscode" | |
}, | |
"explorer.confirmDragAndDrop": false, | |
"[javascript]": { | |
"editor.defaultFormatter": "vscode.typescript-language-features" | |
}, | |
"[html]": { | |
"editor.defaultFormatter": "vscode.html-language-features" | |
}, | |
"[css]": { | |
"editor.defaultFormatter": "esbenp.prettier-vscode" | |
}, | |
"editor.showFoldingControls": "always", | |
"editor.bracketPairColorization.enabled": true, | |
"workbench.activityBar.visible": true, | |
"workbench.statusBar.visible": true, | |
"debug.allowBreakpointsEverywhere": true, | |
"debug.showBreakpointsInOverviewRuler": true, | |
"files.associations": { | |
"*.react": "javascript", | |
"*.svx": "markdown", | |
"*.svelte": "svelte", | |
"*.graphql": "graphql" | |
}, | |
"[typescript]": { | |
"editor.defaultFormatter": "esbenp.prettier-vscode" | |
}, | |
"[json]": { | |
"editor.defaultFormatter": "vscode.json-language-features" | |
}, | |
"javascript.updateImportsOnFileMove.enabled": "always", | |
"tailwindCSS.includeLanguages": { | |
"svelte": "html" | |
}, | |
"workbench.sideBar.location": "right", | |
"editor.inlineSuggest.enabled": true, | |
"tabnine.experimentalAutoImports": true, | |
"editor.accessibilitySupport": "off", | |
"security.workspace.trust.untrustedFiles": "open", | |
"editor.suggestSelection": "first", | |
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue", | |
"explorer.confirmDelete": false, | |
"editor.defaultFormatter": "esbenp.prettier-vscode", | |
"editor.formatOnSaveMode": "modificationsIfAvailable", | |
"go.toolsManagement.autoUpdate": true, | |
"window.zoomLevel": 1, | |
"svelte.enable-ts-plugin": true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"workbench.colorTheme": "Shades of Purple", | |
"terminal.integrated.fontFamily": "Meslo LG M DZ for Powerline", | |
"editor.tabSize": 2, | |
"editor.minimap.enabled": false, | |
"[typescriptreact]": { | |
"editor.defaultFormatter": "esbenp.prettier-vscode" | |
}, | |
"explorer.confirmDragAndDrop": false, | |
"window.zoomLevel": 2, | |
"[javascript]": { | |
"editor.defaultFormatter": "esbenp.prettier-vscode" | |
}, | |
"[html]": { | |
"editor.defaultFormatter": "esbenp.prettier-vscode" | |
}, | |
"editor.showFoldingControls": "always", | |
"workbench.activityBar.visible": true, | |
"workbench.statusBar.visible": true, | |
"debug.allowBreakpointsEverywhere": true, | |
"debug.showBreakpointsInOverviewRuler": true, | |
"files.associations": { | |
"*.svx": "markdown", | |
"*.graphql": "graphql" | |
}, | |
"[typescript]": { | |
"editor.defaultFormatter": "esbenp.prettier-vscode" | |
} | |
} |
Author
swyxio
commented
Jun 9, 2020
temporal laptop zshrc
#### FIG ENV VARIABLES ####
[ -s ~/.fig/shell/pre.sh ] && source ~/.fig/shell/pre.sh
#### END FIG ENV VARIABLES ####
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:/Users/swyx/go/bin:$PATH
export GOPATH=/Users/swyx/go
#Path to your oh-my-zsh installation.
export ZSH=/Users/swyx/.oh-my-zsh
# to stop silly homebrew autoupdate
export HOMEBREW_NO_AUTO_UPDATE=1
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
# ZSH_THEME="robbyrussell"
ZSH_THEME="agnoster"
# ZSH_THEME="awesomepanda"
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion. Case
# sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
alias mv="mv -iv"
alias cp="cp -iv"
alias brew="HOMEBREW_NO_AUTO_UPDATE=1 brew"
alias lsd="ls -ltr" # List files/folders by the most recently changed.
alias zs="source ~/.zshrc"
alias zshrc="vi ~/.zshrc"
alias gphm="git push heroku master"
alias gpom="git push origin main 2> /dev/null || git push origin master"
alias gpo="git push origin "
alias gset="git remote set-url"
alias gs="git status"
alias gadmit="git add . && git commit -m"
alias rnri="react-native run-ios"
alias gc="git checkout"
alias gcb="git checkout -b "
alias gupdatefork="git fetch upstream && git checkout master && git rebase upstream/master"
alias gcm="git checkout main 2> /dev/null || git checkout master"
alias crna="create-react-native-app"
alias cra="create-react-app"
# alias rm=trash
alias fucking=sudo
alias gl="git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all"
alias glr='gl -n 7'
alias git-clean-merged="git branch --merged master | grep -v 'master$' | xargs git branch -d"
alias git-clean-remote-merged="git branch -r --merged | grep -v master | sed 's/origin\///' | xargs -n 1 git push --delete origin"
alias run="npm run"
alias sudomongod="sudo mongod --smallfiles"
## react
alias crapp="cp -R ~/Work/crapp $1 && cd $1 && echo 'CRA ready'"
## yarn
alias yb="yarn build"
alias ys="yarn start"
## amplify
alias a="amplify"
alias ac="amplify console"
alias as="amplify status"
alias ap="amplify push"
alias apy="amplify push --y"
# python and django
alias mkvenv="python3 -m venv env"
alias entervenv="source env/bin/activate"
alias pyarn="pip install -r requirements.txt # install all requirements"
alias pyfreeze="pip freeze > requirements.txt # save all requirements"
alias pyinit="mkvenv && env >> .gitignore"
function pi {
pip install "$1"
pyfreeze
}
alias djrun="python manage.py runserver"
alias pm="python manage.py "
function mkcdir ()
{
mkdir -p -- "$1" &&
cd -P -- "$1"
}
# for fzf https://github.com/junegunn/fzf
alias preview="fzf --preview 'bat --color \"always\" {}'"
alias cat='bat'
## add support for ctrl+o to open selected file in VS Code
export FZF_DEFAULT_OPTS="--bind='ctrl-o:execute(code-insiders {})+abort'"
# export PS1="$ "
# https://twitter.com/wesbos/status/601426471240998912
function t() {
tree -I '.git|node_modules|bower_components|.DS_Store' --dirsfirst --filelimit 15 -L ${1:-3} -aC $2
}
. /usr/local/etc/profile.d/z.sh
#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
#### FIG ENV VARIABLES ####
[[ -s ~/.fig/fig.sh ]] && source ~/.fig/fig.sh
#### END FIG ENV VARIABLES ####
# # >>> conda initialize >>>
# # !! Contents within this block are managed by 'conda init' !!
# __conda_setup="$('/Users/swyx/opt/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
# if [ $? -eq 0 ]; then
# eval "$__conda_setup"
# else
# if [ -f "/Users/swyx/opt/anaconda3/etc/profile.d/conda.sh" ]; then
# . "/Users/swyx/opt/anaconda3/etc/profile.d/conda.sh"
# else
# export PATH="/Users/swyx/opt/anaconda3/bin:$PATH"
# fi
# fi
# unset __conda_setup
# # <<< conda initialize <<<
vimrc
set autoindent
set indentexpr=off
set expandtab
set tabstop=4
set sw=4
set textwidth=80
set nohls
set noshowmatch
syntax enable
setlocal spell spelllang=en_us
set nospell
set background=dark
autocmd VimEnter * set vb t_vb=
set modeline
set nojoinspaces " pesky 2-spaces after the period thing
set shortmess=AITstW " I hate: naggy dialogs, intros, long messages
set noshowcmd
set nowritebackup
set noswapfile
set nobackup
" don't delete whitespace-only lines leaving insert mode:
inoremap <CR> x<BS><CR>x<BS>
inoremap <up> x<BS><up>
inoremap <down> x<BS><down>
nnoremap o ox<BS>
nnoremap O Ox<BS>
" for fzf https://github.com/junegunn/fzf
set rtp+=/usr/local/opt/fzf
" fuck everything about the 'Press ENTER' message:
set showcmd
set shortmess=at
" 2-space indent for html and json files
autocmd BufRead,BufNewFile *.json,*.html,*.css,*.svg set sw=2 tabstop=2
autocmd BufRead,BufNewFile Makefile,makefile,*Makefile,*makefile set noexpandtab
https://twitter.com/chantastic/status/1700234017554235460
determine package manager and run command with it
PO
if [[ -f bun. lockb ]]; then
command bun "$@"
elif pnpm-lock. yaml J]; then TI -f
command ppm "$@"
yarn. lock I]; then elif [ -f
command yarn "$0"
package-lock. json then 1]; -f elif [[
command npm '$@"
else
command pnpm "$@"
fi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment