Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New laptop 2023 #32

Draft
wants to merge 6 commits into
base: 💜
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 59 additions & 20 deletions .bash-preexec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Author: Ryan Caloras (ryan@bashhub.com)
# Forked from Original Author: Glyph Lefkowitz
#
# V0.4.1
# V0.5.0
#

# General Usage:
Expand All @@ -32,16 +32,31 @@
# using: the "DEBUG" trap, and the "PROMPT_COMMAND" variable. If you override
# either of these after bash-preexec has been installed it will most likely break.

# Tell shellcheck what kind of file this is.
# shellcheck shell=bash

# Make sure this is bash that's running and return otherwise.
if [[ -z "${BASH_VERSION:-}" ]]; then
# Use POSIX syntax for this line:
if [ -z "${BASH_VERSION-}" ]; then
return 1;
fi

# We only support Bash 3.1+.
# Note: BASH_VERSINFO is first available in Bash-2.0.
if [[ -z "${BASH_VERSINFO-}" ]] || (( BASH_VERSINFO[0] < 3 || (BASH_VERSINFO[0] == 3 && BASH_VERSINFO[1] < 1) )); then
return 1
fi

# Avoid duplicate inclusion
if [[ "${__bp_imported:-}" == "defined" ]]; then
if [[ -n "${bash_preexec_imported:-}" ]]; then
return 0
fi
__bp_imported="defined"
bash_preexec_imported="defined"

# WARNING: This variable is no longer used and should not be relied upon.
# Use ${bash_preexec_imported} instead.
# shellcheck disable=SC2034
__bp_imported="${bash_preexec_imported}"

# Should be available to each precmd and preexec
# functions, should they want it. $? and $_ are available as $? and $_, but
Expand Down Expand Up @@ -75,7 +90,8 @@ __bp_require_not_readonly() {
# history even if it starts with a space.
__bp_adjust_histcontrol() {
local histcontrol
histcontrol="${HISTCONTROL//ignorespace}"
histcontrol="${HISTCONTROL:-}"
histcontrol="${histcontrol//ignorespace}"
# Replace ignoreboth with ignoredups
if [[ "$histcontrol" == *"ignoreboth"* ]]; then
histcontrol="ignoredups:${histcontrol//ignoreboth}"
Expand All @@ -90,6 +106,10 @@ __bp_adjust_histcontrol() {
# and unset as soon as the trace hook is run.
__bp_preexec_interactive_mode=""

# These arrays are used to add functions to be run before, or after, prompts.
declare -a precmd_functions
declare -a preexec_functions

# Trims leading and trailing whitespace from $2 and writes it to the variable
# name passed as $1
__bp_trim_whitespace() {
Expand Down Expand Up @@ -125,6 +145,9 @@ __bp_interactive_mode() {
__bp_precmd_invoke_cmd() {
# Save the returned value from our last command, and from each process in
# its pipeline. Note: this MUST be the first thing done in this function.
# BP_PIPESTATUS may be unused, ignore
# shellcheck disable=SC2034

__bp_last_ret_value="$?" BP_PIPESTATUS=("${PIPESTATUS[@]}")

# Don't invoke precmds if we are inside an execution of an "original
Expand All @@ -147,19 +170,21 @@ __bp_precmd_invoke_cmd() {
"$precmd_function"
fi
done

__bp_set_ret_value "$__bp_last_ret_value"
}

# Sets a return value in $?. We may want to get access to the $? variable in our
# precmd functions. This is available for instance in zsh. We can simulate it in bash
# by setting the value here.
__bp_set_ret_value() {
return ${1:-}
return ${1:+"$1"}
}

__bp_in_prompt_command() {

local prompt_command_array
IFS=$'\n;' read -rd '' -a prompt_command_array <<< "$PROMPT_COMMAND"
local prompt_command_array IFS=$'\n;'
read -rd '' -a prompt_command_array <<< "${PROMPT_COMMAND[*]:-}"

local trimmed_arg
__bp_trim_whitespace trimmed_arg "${1:-}"
Expand Down Expand Up @@ -227,7 +252,7 @@ __bp_preexec_invoke_exec() {
local this_command
this_command=$(
export LC_ALL=C
HISTTIMEFORMAT= builtin history 1 | sed '1 s/^ *[0-9][0-9]*[* ] //'
HISTTIMEFORMAT='' builtin history 1 | sed '1 s/^ *[0-9][0-9]*[* ] //'
)

# Sanity check to make sure we have something to invoke our function with.
Expand All @@ -244,7 +269,7 @@ __bp_preexec_invoke_exec() {
# Only execute each function if it actually exists.
# Test existence of function with: declare -[fF]
if type -t "$preexec_function" 1>/dev/null; then
__bp_set_ret_value ${__bp_last_ret_value:-}
__bp_set_ret_value "${__bp_last_ret_value:-}"
# Quote our function invocation to prevent issues with IFS
"$preexec_function" "$this_command"
preexec_function_ret_value="$?"
Expand All @@ -265,14 +290,17 @@ __bp_preexec_invoke_exec() {

__bp_install() {
# Exit if we already have this installed.
if [[ "${PROMPT_COMMAND:-}" == *"__bp_precmd_invoke_cmd"* ]]; then
if [[ "${PROMPT_COMMAND[*]:-}" == *"__bp_precmd_invoke_cmd"* ]]; then
return 1;
fi

trap '__bp_preexec_invoke_exec "$_"' DEBUG

# Preserve any prior DEBUG trap as a preexec function
local prior_trap=$(sed "s/[^']*'\(.*\)'[^']*/\1/" <<<"${__bp_trap_string:-}")
local prior_trap
# we can't easily do this with variable expansion. Leaving as sed command.
# shellcheck disable=SC2001
prior_trap=$(sed "s/[^']*'\(.*\)'[^']*/\1/" <<<"${__bp_trap_string:-}")
unset __bp_trap_string
if [[ -n "$prior_trap" ]]; then
eval '__bp_original_debug_trap() {
Expand All @@ -297,17 +325,26 @@ __bp_install() {

local existing_prompt_command
# Remove setting our trap install string and sanitize the existing prompt command string
existing_prompt_command="${PROMPT_COMMAND//$__bp_install_string[;$'\n']}" # Edge case of appending to PROMPT_COMMAND
existing_prompt_command="${existing_prompt_command//$__bp_install_string}"
existing_prompt_command="${PROMPT_COMMAND:-}"
# Edge case of appending to PROMPT_COMMAND
existing_prompt_command="${existing_prompt_command//$__bp_install_string/:}" # no-op
existing_prompt_command="${existing_prompt_command//$'\n':$'\n'/$'\n'}" # remove known-token only
existing_prompt_command="${existing_prompt_command//$'\n':;/$'\n'}" # remove known-token only
__bp_sanitize_string existing_prompt_command "$existing_prompt_command"
if [[ "${existing_prompt_command:-:}" == ":" ]]; then
existing_prompt_command=
fi

# Install our hooks in PROMPT_COMMAND to allow our trap to know when we've
# actually entered something.
PROMPT_COMMAND=$'__bp_precmd_invoke_cmd\n'
if [[ -n "$existing_prompt_command" ]]; then
PROMPT_COMMAND+=${existing_prompt_command}$'\n'
fi;
PROMPT_COMMAND+='__bp_interactive_mode'
PROMPT_COMMAND='__bp_precmd_invoke_cmd'
PROMPT_COMMAND+=${existing_prompt_command:+$'\n'$existing_prompt_command}
if (( BASH_VERSINFO[0] > 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 1) )); then
PROMPT_COMMAND+=('__bp_interactive_mode')
else
# shellcheck disable=SC2179 # PROMPT_COMMAND is not an array in bash <= 5.0
PROMPT_COMMAND+=$'\n__bp_interactive_mode'
fi

# Add two functions to our arrays for convenience
# of definition.
Expand All @@ -328,10 +365,12 @@ __bp_install_after_session_init() {
__bp_require_not_readonly PROMPT_COMMAND HISTCONTROL HISTTIMEFORMAT || return

local sanitized_prompt_command
__bp_sanitize_string sanitized_prompt_command "$PROMPT_COMMAND"
__bp_sanitize_string sanitized_prompt_command "${PROMPT_COMMAND:-}"
if [[ -n "$sanitized_prompt_command" ]]; then
# shellcheck disable=SC2178 # PROMPT_COMMAND is not an array in bash <= 5.0
PROMPT_COMMAND=${sanitized_prompt_command}$'\n'
fi;
# shellcheck disable=SC2179 # PROMPT_COMMAND is not an array in bash <= 5.0
PROMPT_COMMAND+=${__bp_install_string}
}

Expand Down
33 changes: 17 additions & 16 deletions .bash_profile
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,15 @@ command -v jenv &> /dev/null && eval "$(jenv init -)"
# Init DirEnv
command -v direnv &> /dev/null && eval "$(direnv hook bash)"

# Since v2.1 GnuPG have changed the method a daemon starts. They are all started
# on demand now. For more information see:
# https://www.gnupg.org/faq/whats-new-in-2.1.html#autostart
# Found this: https://www.linuxquestions.org/questions/slackware-14/gpg-agent-write-env-file-obsolete-4175608513/
GPG_TTY=$(/usr/bin/tty)
SSH_AUTH_SOCK="$HOME/.gnupg/S.gpg-agent.ssh"
export GPG_TTY SSH_AUTH_SOCK
gpgconf --launch gpg-agent
# # Since v2.1 GnuPG have changed the method a daemon starts. They are all started
# # on demand now. For more information see:
# # https://www.gnupg.org/faq/whats-new-in-2.1.html#autostart
# # Found this: https://www.linuxquestions.org/questions/slackware-14/gpg-agent-write-env-file-obsolete-4175608513/
# GPG_TTY=$(/usr/bin/tty)
# SSH_AUTH_SOCK="$HOME/.gnupg/S.gpg-agent.ssh"
# export GPG_TTY SSH_AUTH_SOCK
# gpgconf --launch gpg-agent
export SSH_AUTH_SOCK="/Users/coreyja/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh"

command -v starship &> /dev/null && eval "$(starship init bash)"

Expand All @@ -118,25 +119,25 @@ function gg {
export PATH="$HOME/bin:$PATH";
export PATH="$HOME/.local/bin:$PATH";

# McFly for better history search
eval "$(mcfly init bash)"
export MCFLY_KEY_SCHEME=vim
export MCFLY_FUZZY=5
command -v atuin &> /dev/null && eval "$(atuin init bash)"

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/homebrew/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
__conda_setup="$('/opt/homebrew/Caskroom/miniconda/base/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/opt/homebrew/anaconda3/etc/profile.d/conda.sh" ]; then
. "/opt/homebrew/anaconda3/etc/profile.d/conda.sh"
if [ -f "/opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh" ]; then
. "/opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh"
else
export PATH="/opt/homebrew/anaconda3/bin:$PATH"
export PATH="/opt/homebrew/Caskroom/miniconda/base/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<

# Add `code` to the `$PATH` for VS Code
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"

export BUN_INSTALL="$HOME/.bun"
export PATH=$BUN_INSTALL/bin:$PATH
11 changes: 7 additions & 4 deletions .bashrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export PATH="/opt/homebrew/bin:$PATH";

# Open in tmux if in a visual shell
if [ "$TERM" == "xterm-256color" ] || [ "$TERM" == "alacritty" ] || [ "$TERM" == "xterm-kitty" ]; then
hash tmux && [ "$INPUTRC" != "~/.fig/nop" ] && [ -z "$TMUX" ] && { tmux attach || exec tmux new-session && exit; }
fi
# # Open in tmux if in a visual shell
# if [ "$TERM" == "xterm-256color" ] || [ "$TERM" == "alacritty" ] || [ "$TERM" == "xterm-kitty" ]; then
# hash tmux && [ "$INPUTRC" != "~/.fig/nop" ] && [ -z "$TMUX" ] && { tmux attach || exec tmux new-session && exit; }
# fi

# bun
[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh
4 changes: 3 additions & 1 deletion .gitconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[user]
name = Corey Alexander
email = coreyja@gmail.com
signingkey = 6CE33F86461BAF1DDDEC19C62803A46741DF1405
signingkey = "/Users/coreyja/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/PublicKeys/36723cbf28608cc1a6b5dcb91bdde605.pub"
[alias]

# View abbreviated SHA, description, and history graph of the latest 20 commits
Expand Down Expand Up @@ -236,3 +236,5 @@

[difftool "delta-always-page"]
cmd = "DELTA_PAGER=\"less -+F\" git diff"
[gpg]
format = ssh
2 changes: 1 addition & 1 deletion Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ group 'Version Managers' do
end

brew 'bash'
brew 'bash-completion2'
# brew 'bash-completion2'

brew 'wget'

Expand Down
15 changes: 15 additions & 0 deletions Library/Application Support/Code/User/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,19 @@
"[python]": {
"editor.formatOnType": true
},
"terminal.integrated.enableBell": true,
"terminal.integrated.profiles.osx": {
"bash": {
"path": "/opt/homebrew/bin/bash",
"args": [
"-l"
],
"icon": "terminal-bash"
},
"tmux": {
"path": "/opt/homebrew/bin/tmux",
"icon": "terminal-tmux"
}
},
"terminal.integrated.defaultProfile.osx": "bash"
}
4 changes: 2 additions & 2 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -e
set -x

pushd "$HOME"
brew update
Expand All @@ -17,7 +17,7 @@ pushd "$HOME"
rustup-init -y
./scripts/install_from_cargo.sh

nvim-update
# nvim-update

mkdir -p .config/vale/styles
vale sync
Expand Down
8 changes: 0 additions & 8 deletions themer-theme/.eslintrc.js

This file was deleted.

1 change: 0 additions & 1 deletion themer-theme/.gitignore

This file was deleted.

47 changes: 0 additions & 47 deletions themer-theme/blink-shell.js

This file was deleted.

Loading