Compare commits

...

15 Commits

8 changed files with 247 additions and 11 deletions

2
.gitignore vendored
View File

@@ -1,3 +1,5 @@
backup/ backup/
skel/.profile-local skel/.profile-local
skel/.profile-private skel/.profile-private
skel/.profile-post-local
skel/.profile-post-private

View File

@@ -1,10 +1,35 @@
Git repo of my personal shell profile variables ## What this is
This is a Git repo of my personal shell profile and preferred working environment. You are free to use it if you think / work like me.
## What does this do?
- works with the package manager to install my preferred tools
- use zsh by default
- enables oh-my-zsh with gentoo colors and the following plugins / settings
- git
- per-directory-history
- zsh-autosuggestions
- zsh-syntax-highlighting
- interactive comments
- `RM_STAR_WAIT` - wait 10 seconds before agreeing to `rm *`
- effectively unlimited history
- use phpenv, rbenv, pyenv, etc if installed
- vim as default editor with the following plugins / settings
- vim-fugitive
- vim-sleuth
- Vundle
- ignorecase / smartcase search
- `_` character counted as iskeyword
- all of the above with automation conveniences
- installer script, so i can run on any new PC / VM
- backs up current configs
- allows you to set local configs tracked separately from git
## Installing ## Installing
### Quick Install ### Quick Install
``` ```
curl https://gitea.madumlao.com/madumlao/madumlao-profile/src/branch/master/install.sh | bash curl https://gitea.madumlao.com/madumlao/madumlao-profile/raw/branch/master/install.sh | bash
``` ```
### Manual Install ### Manual Install

View File

@@ -3,7 +3,7 @@
# tested on os-release 9,3 # tested on os-release 9,3
APP_DIR="$(dirname "$0")" APP_DIR="$(dirname "$0")"
echo "Run an apt update" echo "Run a dnf update"
if sudo -l dnf > /dev/null; then if sudo -l dnf > /dev/null; then
sudo dnf check-update sudo dnf check-update
else else
@@ -11,7 +11,7 @@ else
fi fi
echo "Install git and friends" echo "Install git and friends"
if sudo -l apt > /dev/null; then if sudo -l dnf > /dev/null; then
sudo dnf install -y git sudo dnf install -y git
else else
echo "Unable to autoinstall git and friends, please install manually" echo "Unable to autoinstall git and friends, please install manually"
@@ -70,7 +70,7 @@ done
IFS="$OLDIFS" IFS="$OLDIFS"
echo "Install vim and friends" echo "Install vim and friends"
if sudo -l apt > /dev/null; then if sudo -l dnf > /dev/null; then
sudo dnf install -y vim-enhanced sudo dnf install -y vim-enhanced
else else
echo "Unable to autoinstall vim and friends, please install manually" echo "Unable to autoinstall vim and friends, please install manually"

View File

@@ -34,7 +34,7 @@ shopt -s checkwinsize
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot) debian_chroot=$(cat /etc/debian_chroot)
fi fi
$()
# set a fancy prompt (non-color, unless we know we "want" color) # set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in case "$TERM" in
xterm*) color_prompt=yes;; xterm*) color_prompt=yes;;
@@ -72,6 +72,15 @@ xterm*|rxvt*)
;; ;;
esac esac
# Add goodies to PS1
export BASE_PS1="$PS1"
export BASE_PS1="$(echo "$BASE_PS1" | sed 's!\\\$ $!!g')"
export BASE_PS1_END=' \$ '
# show return value if prompt is nonzero
export BASH_GOODIES_RETURNVAL='$([ "$?" = 0 ] && echo "" || echo " \e[31m\][$?]\[\e[0m\]")'
PS1="${BASE_PS1}${BASH_GOODIES_RETURNVAL}${BASE_PS1_END}"
# enable color support of ls and also add handy aliases # enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"

View File

@@ -0,0 +1,178 @@
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
if [[ -o interactive ]]; then
if [ "${ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX-}""$TERM" != "tmux-256color" -a "${ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX-}""$TERM" != "screen" -a "${ITERM_SHELL_INTEGRATION_INSTALLED-}" = "" -a "$TERM" != linux -a "$TERM" != dumb ]; then
ITERM_SHELL_INTEGRATION_INSTALLED=Yes
ITERM2_SHOULD_DECORATE_PROMPT="1"
# Indicates start of command output. Runs just before command executes.
iterm2_before_cmd_executes() {
if [ "$TERM_PROGRAM" = "iTerm.app" ]; then
printf "\033]133;C;\r\007"
else
printf "\033]133;C;\007"
fi
}
iterm2_set_user_var() {
printf "\033]1337;SetUserVar=%s=%s\007" "$1" $(printf "%s" "$2" | base64 | tr -d '\n')
}
# Users can write their own version of this method. It should call
# iterm2_set_user_var but not produce any other output.
# e.g., iterm2_set_user_var currentDirectory $PWD
# Accessible in iTerm2 (in a badge now, elsewhere in the future) as
# \(user.currentDirectory).
whence -v iterm2_print_user_vars > /dev/null 2>&1
if [ $? -ne 0 ]; then
iterm2_print_user_vars() {
true
}
fi
iterm2_print_state_data() {
local _iterm2_hostname="${iterm2_hostname-}"
if [ -z "${iterm2_hostname:-}" ]; then
_iterm2_hostname=$(hostname -f 2>/dev/null)
fi
printf "\033]1337;RemoteHost=%s@%s\007" "$USER" "${_iterm2_hostname-}"
printf "\033]1337;CurrentDir=%s\007" "$PWD"
iterm2_print_user_vars
}
# Report return code of command; runs after command finishes but before prompt
iterm2_after_cmd_executes() {
printf "\033]133;D;%s\007" "$STATUS"
iterm2_print_state_data
}
# Mark start of prompt
iterm2_prompt_mark() {
printf "\033]133;A\007"
}
# Mark end of prompt
iterm2_prompt_end() {
printf "\033]133;B\007"
}
# There are three possible paths in life.
#
# 1) A command is entered at the prompt and you press return.
# The following steps happen:
# * iterm2_preexec is invoked
# * PS1 is set to ITERM2_PRECMD_PS1
# * ITERM2_SHOULD_DECORATE_PROMPT is set to 1
# * The command executes (possibly reading or modifying PS1)
# * iterm2_precmd is invoked
# * ITERM2_PRECMD_PS1 is set to PS1 (as modified by command execution)
# * PS1 gets our escape sequences added to it
# * zsh displays your prompt
# * You start entering a command
#
# 2) You press ^C while entering a command at the prompt.
# The following steps happen:
# * (iterm2_preexec is NOT invoked)
# * iterm2_precmd is invoked
# * iterm2_before_cmd_executes is called since we detected that iterm2_preexec was not run
# * (ITERM2_PRECMD_PS1 and PS1 are not messed with, since PS1 already has our escape
# sequences and ITERM2_PRECMD_PS1 already has PS1's original value)
# * zsh displays your prompt
# * You start entering a command
#
# 3) A new shell is born.
# * PS1 has some initial value, either zsh's default or a value set before this script is sourced.
# * iterm2_precmd is invoked
# * ITERM2_SHOULD_DECORATE_PROMPT is initialized to 1
# * ITERM2_PRECMD_PS1 is set to the initial value of PS1
# * PS1 gets our escape sequences added to it
# * Your prompt is shown and you may begin entering a command.
#
# Invariants:
# * ITERM2_SHOULD_DECORATE_PROMPT is 1 during and just after command execution, and "" while the prompt is
# shown and until you enter a command and press return.
# * PS1 does not have our escape sequences during command execution
# * After the command executes but before a new one begins, PS1 has escape sequences and
# ITERM2_PRECMD_PS1 has PS1's original value.
iterm2_decorate_prompt() {
# This should be a raw PS1 without iTerm2's stuff. It could be changed during command
# execution.
ITERM2_PRECMD_PS1="$PS1"
ITERM2_SHOULD_DECORATE_PROMPT=""
# Add our escape sequences just before the prompt is shown.
# Use ITERM2_SQUELCH_MARK for people who can't modify PS1 directly, like powerlevel9k users.
# This is gross but I had a heck of a time writing a correct if statetment for zsh 5.0.2.
local PREFIX=""
if [[ $PS1 == *"$(iterm2_prompt_mark)"* ]]; then
PREFIX=""
elif [[ "${ITERM2_SQUELCH_MARK-}" != "" ]]; then
PREFIX=""
else
PREFIX="%{$(iterm2_prompt_mark)%}"
fi
PS1="$PREFIX$PS1%{$(iterm2_prompt_end)%}"
ITERM2_DECORATED_PS1="$PS1"
}
iterm2_precmd() {
local STATUS="$?"
if [ -z "${ITERM2_SHOULD_DECORATE_PROMPT-}" ]; then
# You pressed ^C while entering a command (iterm2_preexec did not run)
iterm2_before_cmd_executes
if [ "$PS1" != "${ITERM2_DECORATED_PS1-}" ]; then
# PS1 changed, perhaps in another precmd. See issue 9938.
ITERM2_SHOULD_DECORATE_PROMPT="1"
fi
fi
iterm2_after_cmd_executes "$STATUS"
if [ -n "$ITERM2_SHOULD_DECORATE_PROMPT" ]; then
iterm2_decorate_prompt
fi
}
# This is not run if you press ^C while entering a command.
iterm2_preexec() {
# Set PS1 back to its raw value prior to executing the command.
PS1="$ITERM2_PRECMD_PS1"
ITERM2_SHOULD_DECORATE_PROMPT="1"
iterm2_before_cmd_executes
}
# If hostname -f is slow on your system set iterm2_hostname prior to
# sourcing this script. We know it is fast on macOS so we don't cache
# it. That lets us handle the hostname changing like when you attach
# to a VPN.
if [ -z "${iterm2_hostname-}" ]; then
if [ "$(uname)" != "Darwin" ]; then
iterm2_hostname=`hostname -f 2>/dev/null`
# Some flavors of BSD (i.e. NetBSD and OpenBSD) don't have the -f option.
if [ $? -ne 0 ]; then
iterm2_hostname=`hostname`
fi
fi
fi
[[ -z ${precmd_functions-} ]] && precmd_functions=()
precmd_functions=($precmd_functions iterm2_precmd)
[[ -z ${preexec_functions-} ]] && preexec_functions=()
preexec_functions=($preexec_functions iterm2_preexec)
iterm2_print_state_data
printf "\033]1337;ShellIntegrationVersion=14;shell=zsh\007"
fi
fi

View File

@@ -93,11 +93,18 @@ if [ -z "$PYENV_DISABLE" ] && [ -d "$PYENV_ROOT/bin" ]; then
fi fi
# perl # perl
export PATH="/home/madumlao/perl5/bin${PATH:+:${PATH}}"; export PATH; export PATH="$HOME/perl5/bin${PATH:+:${PATH}}"
export PERL5LIB="/home/madumlao/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB; export PERL5LIB="$HOME/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"
export PERL_LOCAL_LIB_ROOT="/home/madumlao/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT; export PERL_LOCAL_LIB_ROOT="$HOME/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"
export PERL_MB_OPT="--install_base \"/home/madumlao/perl5\""; export PERL_MB_OPT; export PERL_MB_OPT="--install_base \"$HOME/perl5\""
export PERL_MM_OPT="INSTALL_BASE=/home/madumlao/perl5"; export PERL_MM_OPT; export PERL_MM_OPT="INSTALL_BASE=$HOME/perl5"
# aliases # aliases
alias less='less -i -r' alias less='less -i -r'
if which winget.exe >/dev/null 2>&1; then
alias winget="$(which winget.exe)"
fi
# profile variables that need to be defined late
[ -f "$HOME/.profile-post-local" ] && source "$HOME/.profile-post-local"
[ -f "$HOME/.profile-post-private" ] && source "$HOME/.profile-post-private"

View File

@@ -8,3 +8,11 @@ source $HOME/.profile
if whence kubectl > /dev/null && [ "$PROFILE_ENABLE_KUBECTL" ]; then if whence kubectl > /dev/null && [ "$PROFILE_ENABLE_KUBECTL" ]; then
source <(kubectl completion zsh) source <(kubectl completion zsh)
fi fi
# MacOS specific
if [ "$(uname)" = "Darwin" ]; then
if [ -f .iterm2_shell_integration ]; then
source .iterm2_shell_integration
fi
fi

View File

@@ -50,6 +50,9 @@ plugins=(git per-directory-history zsh-autosuggestions zsh-syntax-highlighting)
# User configuration # User configuration
source $ZSH/oh-my-zsh.sh source $ZSH/oh-my-zsh.sh
# setup colors
ZSH_HIGHLIGHT_STYLES[comment]=fg=cyan,bold
# interactive comments # interactive comments
setopt interactivecomments setopt interactivecomments
@@ -71,6 +74,7 @@ SAVEHIST=$HISTSIZE
setopt BANG_HIST # Treat the '!' character specially during expansion. setopt BANG_HIST # Treat the '!' character specially during expansion.
setopt HIST_BEEP # Beep when accessing nonexistent history. setopt HIST_BEEP # Beep when accessing nonexistent history.
setopt HIST_LEX_WORDS # parse quotes when parsing history setopt HIST_LEX_WORDS # parse quotes when parsing history
setopt HIST_IGNORE_SPACE # dont save commands starting with space
# set GPG_TTY # set GPG_TTY
if [ "$GPG_TTY" = "" ]; then if [ "$GPG_TTY" = "" ]; then
@@ -82,3 +86,6 @@ emulate bash
[ -f "$HOME/.rc-local" ] && source "$HOME/.rc-local" [ -f "$HOME/.rc-local" ] && source "$HOME/.rc-local"
emulate zsh emulate zsh
[ -f "$HOME/.zshrc-local" ] && source "$HOME/.zshrc-local" [ -f "$HOME/.zshrc-local" ] && source "$HOME/.zshrc-local"
# Add return value to prompt if nonzero
PS1='%(!.%B%F{red}.%B%F{green}%n@)%m %F{blue}%(!.%1~.%~) ${vcs_info_msg_0_}%F{blue}%(?..%F{red}[%?] )%F{blue}%(!.#.$)%b%f '