Compare commits
15 Commits
cc4eb4f544
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 63b2ea7388 | |||
| bd9bc865ab | |||
| 1a943907db | |||
| e903a3a256 | |||
| 1c69b6de79 | |||
| f203391ee6 | |||
| 2a71415f0f | |||
| 2a6cc1709a | |||
| 954ee8eadb | |||
| 935da20ddf | |||
| a1e8f2f9f9 | |||
| ddec4491fd | |||
| e5c1bba6a6 | |||
| ab660d570d | |||
| a583e27d69 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
||||
backup/
|
||||
skel/.profile-local
|
||||
skel/.profile-private
|
||||
skel/.profile-post-local
|
||||
skel/.profile-post-private
|
||||
|
||||
29
README.md
29
README.md
@@ -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
|
||||
### 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
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# tested on os-release 9,3
|
||||
APP_DIR="$(dirname "$0")"
|
||||
|
||||
echo "Run an apt update"
|
||||
echo "Run a dnf update"
|
||||
if sudo -l dnf > /dev/null; then
|
||||
sudo dnf check-update
|
||||
else
|
||||
@@ -11,7 +11,7 @@ else
|
||||
fi
|
||||
|
||||
echo "Install git and friends"
|
||||
if sudo -l apt > /dev/null; then
|
||||
if sudo -l dnf > /dev/null; then
|
||||
sudo dnf install -y git
|
||||
else
|
||||
echo "Unable to autoinstall git and friends, please install manually"
|
||||
@@ -70,7 +70,7 @@ done
|
||||
IFS="$OLDIFS"
|
||||
|
||||
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
|
||||
else
|
||||
echo "Unable to autoinstall vim and friends, please install manually"
|
||||
|
||||
11
skel/.bashrc
11
skel/.bashrc
@@ -34,7 +34,7 @@ shopt -s checkwinsize
|
||||
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_prompt=yes;;
|
||||
@@ -72,6 +72,15 @@ xterm*|rxvt*)
|
||||
;;
|
||||
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
|
||||
if [ -x /usr/bin/dircolors ]; then
|
||||
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
||||
|
||||
178
skel/.iterm2_shell_integration.zsh
Normal file
178
skel/.iterm2_shell_integration.zsh
Normal 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
|
||||
@@ -93,11 +93,18 @@ if [ -z "$PYENV_DISABLE" ] && [ -d "$PYENV_ROOT/bin" ]; then
|
||||
fi
|
||||
|
||||
# perl
|
||||
export PATH="/home/madumlao/perl5/bin${PATH:+:${PATH}}"; export PATH;
|
||||
export PERL5LIB="/home/madumlao/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
|
||||
export PERL_LOCAL_LIB_ROOT="/home/madumlao/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
|
||||
export PERL_MB_OPT="--install_base \"/home/madumlao/perl5\""; export PERL_MB_OPT;
|
||||
export PERL_MM_OPT="INSTALL_BASE=/home/madumlao/perl5"; export PERL_MM_OPT;
|
||||
export PATH="$HOME/perl5/bin${PATH:+:${PATH}}"
|
||||
export PERL5LIB="$HOME/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"
|
||||
export PERL_LOCAL_LIB_ROOT="$HOME/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"
|
||||
export PERL_MB_OPT="--install_base \"$HOME/perl5\""
|
||||
export PERL_MM_OPT="INSTALL_BASE=$HOME/perl5"
|
||||
|
||||
# aliases
|
||||
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"
|
||||
|
||||
@@ -8,3 +8,11 @@ source $HOME/.profile
|
||||
if whence kubectl > /dev/null && [ "$PROFILE_ENABLE_KUBECTL" ]; then
|
||||
source <(kubectl completion zsh)
|
||||
fi
|
||||
|
||||
# MacOS specific
|
||||
if [ "$(uname)" = "Darwin" ]; then
|
||||
if [ -f .iterm2_shell_integration ]; then
|
||||
source .iterm2_shell_integration
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -50,6 +50,9 @@ plugins=(git per-directory-history zsh-autosuggestions zsh-syntax-highlighting)
|
||||
# User configuration
|
||||
source $ZSH/oh-my-zsh.sh
|
||||
|
||||
# setup colors
|
||||
ZSH_HIGHLIGHT_STYLES[comment]=fg=cyan,bold
|
||||
|
||||
# interactive comments
|
||||
setopt interactivecomments
|
||||
|
||||
@@ -71,6 +74,7 @@ SAVEHIST=$HISTSIZE
|
||||
setopt BANG_HIST # Treat the '!' character specially during expansion.
|
||||
setopt HIST_BEEP # Beep when accessing nonexistent history.
|
||||
setopt HIST_LEX_WORDS # parse quotes when parsing history
|
||||
setopt HIST_IGNORE_SPACE # dont save commands starting with space
|
||||
|
||||
# set GPG_TTY
|
||||
if [ "$GPG_TTY" = "" ]; then
|
||||
@@ -82,3 +86,6 @@ emulate bash
|
||||
[ -f "$HOME/.rc-local" ] && source "$HOME/.rc-local"
|
||||
emulate zsh
|
||||
[ -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 '
|
||||
|
||||
Reference in New Issue
Block a user