Compare commits
29 Commits
58b917efb1
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 63b2ea7388 | |||
| bd9bc865ab | |||
| 1a943907db | |||
| e903a3a256 | |||
| 1c69b6de79 | |||
| f203391ee6 | |||
| 2a71415f0f | |||
| 2a6cc1709a | |||
| 954ee8eadb | |||
| 935da20ddf | |||
| a1e8f2f9f9 | |||
| ddec4491fd | |||
| e5c1bba6a6 | |||
| ab660d570d | |||
| a583e27d69 | |||
| cc4eb4f544 | |||
| 0a659528a4 | |||
| 49b97d5697 | |||
| 0ba21d0238 | |||
| b141fdc91e | |||
| e1c9afccf4 | |||
| 853b75288a | |||
| 3337f6d46e | |||
| 02597326f1 | |||
| d8dff46fdc | |||
| e2d7019732 | |||
| 1c648e8df5 | |||
| 512be28cd2 | |||
| 6f4eb81245 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -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
|
||||||
|
|||||||
34
README.md
34
README.md
@@ -1,6 +1,38 @@
|
|||||||
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
|
||||||
|
|
||||||
|
```
|
||||||
|
curl https://gitea.madumlao.com/madumlao/madumlao-profile/raw/branch/master/install.sh | bash
|
||||||
|
```
|
||||||
|
|
||||||
|
### Manual Install
|
||||||
Copy this directory somewhere in your home directory. The directory should be persistent, so probably keep this in your "projects" directory or somewhere similar. If in doubt, you can keep this under `.local/share/madumlao-profile`.
|
Copy this directory somewhere in your home directory. The directory should be persistent, so probably keep this in your "projects" directory or somewhere similar. If in doubt, you can keep this under `.local/share/madumlao-profile`.
|
||||||
|
|
||||||
Next, run the `install.sh` script. It should backup your existing profile and replace it with symlinks to this version.
|
Next, run the `install.sh` script. It should backup your existing profile and replace it with symlinks to this version.
|
||||||
|
|||||||
80
install-rhel.sh
Executable file
80
install-rhel.sh
Executable file
@@ -0,0 +1,80 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# run by install.sh
|
||||||
|
# tested on os-release 9,3
|
||||||
|
APP_DIR="$(dirname "$0")"
|
||||||
|
|
||||||
|
echo "Run a dnf update"
|
||||||
|
if sudo -l dnf > /dev/null; then
|
||||||
|
sudo dnf check-update
|
||||||
|
else
|
||||||
|
echo "Unable to run dnf commands, please install manually"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Install git and friends"
|
||||||
|
if sudo -l dnf > /dev/null; then
|
||||||
|
sudo dnf install -y git
|
||||||
|
else
|
||||||
|
echo "Unable to autoinstall git and friends, please install manually"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Install zsh and friends"
|
||||||
|
if sudo -l dnf > /dev/null; then
|
||||||
|
sudo dnf install -y zsh PackageKit-command-not-found sqlite
|
||||||
|
else
|
||||||
|
echo "Unable to autoinstall zsh and friends, please install manually"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Install oh-my-zsh and plugins"
|
||||||
|
if ! [ -d "$HOME/.oh-my-zsh" ]; then
|
||||||
|
git clone https://github.com/ohmyzsh/ohmyzsh "$HOME/.oh-my-zsh"
|
||||||
|
fi
|
||||||
|
|
||||||
|
(
|
||||||
|
cd "$HOME/.oh-my-zsh/plugins"
|
||||||
|
git clone https://github.com/zsh-users/zsh-autosuggestions
|
||||||
|
git clone https://github.com/zsh-users/zsh-syntax-highlighting
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "Changing default shell"
|
||||||
|
ZSH_PATH="$(which zsh)"
|
||||||
|
if [ -x "$ZSH_PATH" ]; then
|
||||||
|
if sudo -l chsh -s $ZSH_PATH $USER; then
|
||||||
|
sudo chsh -s $ZSH_PATH $USER
|
||||||
|
elif sudo -l usermod -s $ZSH_PATH $USER; then
|
||||||
|
sudo usermod -s $ZSH_PATH $USER
|
||||||
|
else
|
||||||
|
echo "Cannot change shell using sudo, trying password"
|
||||||
|
if ! chsh -s "$ZSH_PATH"; then
|
||||||
|
echo "Unable to change shell to $ZSH_PATH, please change shell manually"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "No zsh available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
SKEL_DIR="$APP_DIR/skel"
|
||||||
|
BACK_DIR="$APP_DIR/backup"
|
||||||
|
|
||||||
|
echo "Backing up original profile under $BACK_DIR"
|
||||||
|
mkdir -pv "$BACK_DIR"
|
||||||
|
|
||||||
|
cd "$SKEL_DIR"
|
||||||
|
OLDIFS="$IFS"
|
||||||
|
IFS=$'\n'
|
||||||
|
for x in $(ls -a); do
|
||||||
|
[ "$x" = '.' ] || [ "$x" = '..' ] && continue;
|
||||||
|
[ "$x" = '.profile-local' ] || [ "$x" = '.profile-private' ] && continue;
|
||||||
|
[ -r "$HOME/$x" ] && echo -ne "Backup: " && mv -v "$HOME/$x" "$BACK_DIR"
|
||||||
|
echo -ne "Linking: " && ln -srv "$(pwd)/$x" "$HOME"
|
||||||
|
done
|
||||||
|
IFS="$OLDIFS"
|
||||||
|
|
||||||
|
echo "Install vim and friends"
|
||||||
|
if sudo -l dnf > /dev/null; then
|
||||||
|
sudo dnf install -y vim-enhanced
|
||||||
|
else
|
||||||
|
echo "Unable to autoinstall vim and friends, please install manually"
|
||||||
|
fi
|
||||||
|
mkdir -pv "$HOME/.vim/bundle"
|
||||||
|
git clone https://github.com/VundleVim/Vundle.vim "$HOME/.vim/bundle/Vundle.vim"
|
||||||
|
vim +PluginInstall +qall
|
||||||
85
install-ubuntu.sh
Executable file
85
install-ubuntu.sh
Executable file
@@ -0,0 +1,85 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# run by install.sh
|
||||||
|
APP_DIR="$(dirname "$0")"
|
||||||
|
|
||||||
|
echo "Run an apt update"
|
||||||
|
if sudo -l apt > /dev/null; then
|
||||||
|
sudo apt update
|
||||||
|
else
|
||||||
|
echo "Unable to run apt commands, please install manually"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Install git and friends"
|
||||||
|
if sudo -l apt > /dev/null; then
|
||||||
|
sudo apt install git
|
||||||
|
else
|
||||||
|
echo "Unable to autoinstall git and friends, please install manually"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Install zsh and friends"
|
||||||
|
if sudo -l apt > /dev/null; then
|
||||||
|
sudo apt install zsh command-not-found
|
||||||
|
else
|
||||||
|
echo "Unable to autoinstall zsh and friends, please install manually"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Install oh-my-zsh and plugins"
|
||||||
|
if ! [ -d "$HOME/.oh-my-zsh" ]; then
|
||||||
|
git clone https://github.com/ohmyzsh/ohmyzsh "$HOME/.oh-my-zsh"
|
||||||
|
fi
|
||||||
|
|
||||||
|
(
|
||||||
|
cd "$HOME/.oh-my-zsh/plugins"
|
||||||
|
git clone https://github.com/zsh-users/zsh-autosuggestions
|
||||||
|
git clone https://github.com/zsh-users/zsh-syntax-highlighting
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "Changing default shell"
|
||||||
|
ZSH_PATH="$(which zsh)"
|
||||||
|
if [ -x "$ZSH_PATH" ]; then
|
||||||
|
if sudo -l chsh -s $ZSH_PATH $USER; then
|
||||||
|
sudo chsh -s $ZSH_PATH $USER
|
||||||
|
elif sudo -l usermod -s $ZSH_PATH $USER; then
|
||||||
|
sudo usermod -s $ZSH_PATH $USER
|
||||||
|
else
|
||||||
|
echo "Cannot change shell using sudo, trying password"
|
||||||
|
if ! chsh -s "$ZSH_PATH"; then
|
||||||
|
echo "Unable to change shell to $ZSH_PATH, please change shell manually"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "No zsh available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
SKEL_DIR="$APP_DIR/skel"
|
||||||
|
BACK_DIR="$APP_DIR/backup"
|
||||||
|
|
||||||
|
echo "Backing up original profile under $BACK_DIR"
|
||||||
|
mkdir -pv "$BACK_DIR"
|
||||||
|
|
||||||
|
cd "$SKEL_DIR"
|
||||||
|
OLDIFS="$IFS"
|
||||||
|
IFS=$'\n'
|
||||||
|
for x in $(ls -a); do
|
||||||
|
[ "$x" = '.' ] || [ "$x" = '..' ] && continue;
|
||||||
|
[ "$x" = '.profile-local' ] || [ "$x" = '.profile-private' ] && continue;
|
||||||
|
[ -r "$HOME/$x" ] && echo -ne "Backup: " && mv -v "$HOME/$x" "$BACK_DIR"
|
||||||
|
echo -ne "Linking: " && ln -srv "$(pwd)/$x" "$HOME"
|
||||||
|
done
|
||||||
|
IFS="$OLDIFS"
|
||||||
|
|
||||||
|
echo "Install vim-nox and friends"
|
||||||
|
if sudo -l apt > /dev/null; then
|
||||||
|
sudo apt install vim-nox
|
||||||
|
else
|
||||||
|
echo "Unable to autoinstall vim-nox and friends, please install manually"
|
||||||
|
fi
|
||||||
|
mkdir -pv "$HOME/.vim/bundle"
|
||||||
|
git clone https://github.com/VundleVim/Vundle.vim "$HOME/.vim/bundle/Vundle.vim"
|
||||||
|
vim +PluginInstall +qall
|
||||||
|
|
||||||
|
echo "Set vim-nox as the default system editor"
|
||||||
|
VIM_PATH="$(which vim.nox)"
|
||||||
|
if [ -x "$VIM_PATH" ]; then
|
||||||
|
sudo update-alternatives --set editor "$VIM_PATH"
|
||||||
|
fi
|
||||||
106
install.sh
106
install.sh
@@ -1,72 +1,48 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
APP_DIR="$(dirname "$0")"
|
if ! [ -t 0 ]; then
|
||||||
|
echo "exec from pipe"
|
||||||
|
DOWNLOAD_APP=y
|
||||||
|
APP_DIR="$HOME/.local/share/madumlao-profile"
|
||||||
|
else
|
||||||
|
DOWNLOAD_APP=
|
||||||
|
APP_DIR="$(dirname "$0")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$DOWNLOAD_APP" ]; then
|
||||||
|
echo "Downloading master copy"
|
||||||
|
PARENT_DIR="$(dirname "$APP_DIR")"
|
||||||
|
mkdir -pv "$PARENT_DIR"
|
||||||
|
if [ -x git ]; then
|
||||||
|
cd "$PARENT_DIR"
|
||||||
|
git clone https://gitea.madumlao.com/madumlao/madumlao-profile
|
||||||
|
else
|
||||||
|
curl -o madumlao-profile-master.tar.gz https://gitea.madumlao.com/madumlao/madumlao-profile/archive/master.tar.gz
|
||||||
|
tar -zxf madumlao-profile-master.tar.gz -C "$PARENT_DIR"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Set pwd to $APP_DIR"
|
||||||
cd "$APP_DIR"
|
cd "$APP_DIR"
|
||||||
APP_DIR="$(pwd)"
|
APP_DIR="$(pwd)"
|
||||||
|
|
||||||
echo "Install zsh and friends"
|
if [ "$(uname)" == "Linux" ]; then
|
||||||
if sudo -l apt; then
|
# detect WSL
|
||||||
sudo apt install zsh command-not-found
|
if uname -r | grep -q WSL > /dev/null; then
|
||||||
else
|
export PROFILE_WSL=y
|
||||||
echo "Unable to autoinstall zsh and friends, please install manually"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Install oh-my-zsh and plugins"
|
|
||||||
if ! [ -d "$HOME/.oh-my-zsh" ]; then
|
|
||||||
git clone https://github.com/ohmyzsh/ohmyzsh "$HOME/.oh-my-zsh"
|
|
||||||
fi
|
|
||||||
|
|
||||||
(
|
|
||||||
cd "$HOME/.oh-my-zsh/plugins"
|
|
||||||
git clone https://github.com/zsh-users/zsh-autosuggestions
|
|
||||||
git clone https://github.com/zsh-users/zsh-syntax-highlighting
|
|
||||||
)
|
|
||||||
|
|
||||||
echo "Changing default shell"
|
|
||||||
ZSH_PATH="$(which zsh)"
|
|
||||||
if [ -x "$ZSH_PATH" ]; then
|
|
||||||
if sudo -l chsh -s $ZSH_PATH $USER; then
|
|
||||||
sudo chsh -s $ZSH_PATH $USER
|
|
||||||
elif sudo -l usermod -s $ZSH_PATH $USER; then
|
|
||||||
sudo usermod -s $ZSH_PATH $USER
|
|
||||||
else
|
|
||||||
echo "Cannot change shell using sudo, trying password"
|
|
||||||
if ! chsh -s "$ZSH_PATH"; then
|
|
||||||
echo "Unable to change shell to $ZSH_PATH, please change shell manually"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
source /etc/os-release
|
||||||
|
export PROFILE_DISTRO="$ID"
|
||||||
|
export PROFILE_DISTRO_VERSION="$VERSION_ID"
|
||||||
|
export PROFILE_DISTRO_CODENAME="$VERSION_CODENAME"
|
||||||
|
export PROFILE_DISTRO_FAMILY="$ID_LIKE"
|
||||||
|
case "$PROFILE_DISTRO" in
|
||||||
|
ubuntu ) ./install-ubuntu.sh ;;
|
||||||
|
ol | rhel ) ./install-rhel.sh ;;
|
||||||
|
* ) echo "Unknown distro, install manually"
|
||||||
|
esac
|
||||||
|
elif [ "$(uname)" == "Darwin" ]; then
|
||||||
|
echo TODO: install-macos.sh
|
||||||
else
|
else
|
||||||
echo "No zsh available"
|
echo Unsupported environment, need to manual install
|
||||||
fi
|
|
||||||
|
|
||||||
SKEL_DIR="$APP_DIR/skel"
|
|
||||||
BACK_DIR="$APP_DIR/backup"
|
|
||||||
|
|
||||||
echo "Backing up original profile under $BACK_DIR"
|
|
||||||
mkdir -pv "$BACK_DIR"
|
|
||||||
|
|
||||||
cd "$SKEL_DIR"
|
|
||||||
OLDIFS="$IFS"
|
|
||||||
IFS=$'\n'
|
|
||||||
for x in $(ls -a); do
|
|
||||||
[ "$x" = '.' ] || [ "$x" = '..' ] && continue;
|
|
||||||
[ "$x" = '.profile-local' ] || [ "$x" = '.profile-private' ] && continue;
|
|
||||||
[ -r "$HOME/$x" ] && echo -ne "Backup: " && mv -v "$HOME/$x" "$BACK_DIR"
|
|
||||||
echo -ne "Linking: " && ln -srv "$(pwd)/$x" "$HOME"
|
|
||||||
done
|
|
||||||
IFS="$OLDIFS"
|
|
||||||
|
|
||||||
echo "Install vim-nox and friends"
|
|
||||||
if sudo -l apt; then
|
|
||||||
sudo apt install vim-nox git
|
|
||||||
else
|
|
||||||
echo "Unable to autoinstall vim-nox and friends, please install manually"
|
|
||||||
fi
|
|
||||||
mkdir -pv "$HOME/.vim/bundle"
|
|
||||||
git clone https://github.com/VundleVim/Vundle.vim "$HOME/.vim/bundle/Vundle.vim"
|
|
||||||
vim +PluginInstall +qall
|
|
||||||
|
|
||||||
echo "Set vim-nox as the default system editor"
|
|
||||||
VIM_PATH="$(which vim.nox)"
|
|
||||||
if [ -x "$VIM_PATH" ]; then
|
|
||||||
sudo update-alternatives --set editor "$VIM_PATH"
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
15
skel/.bashrc
15
skel/.bashrc
@@ -16,8 +16,8 @@ HISTCONTROL=ignoreboth
|
|||||||
shopt -s histappend
|
shopt -s histappend
|
||||||
|
|
||||||
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
||||||
HISTSIZE=1000
|
HISTSIZE=-1
|
||||||
HISTFILESIZE=2000
|
HISTFILESIZE=-1
|
||||||
|
|
||||||
# check the window size after each command and, if necessary,
|
# check the window size after each command and, if necessary,
|
||||||
# update the values of LINES and COLUMNS.
|
# update the values of LINES and COLUMNS.
|
||||||
@@ -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)"
|
||||||
|
|||||||
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
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
export TZ="Asia/Manila"
|
export TZ="Asia/Manila"
|
||||||
export PATH="/usr/local/bin:$PATH"
|
export PATH="/usr/local/bin:$PATH"
|
||||||
export PATH="$HOME/bin:$PATH"
|
export PATH="$HOME/bin:$PATH"
|
||||||
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
export PATH="$HOME/.crypt/bin:$PATH"
|
export PATH="$HOME/.crypt/bin:$PATH"
|
||||||
|
|
||||||
# set your umask
|
# set your umask
|
||||||
@@ -58,7 +59,7 @@ if [ -z "$PHPENV_DISABLE" ] && [ -d "$PHPENV_ROOT/bin" ]; then
|
|||||||
eval "$(phpenv init -)"
|
eval "$(phpenv init -)"
|
||||||
|
|
||||||
# php-build
|
# php-build
|
||||||
export PHP_BUILD_CONFIGURE_OPTS="--with-libdir=lib --with-pear --with-ldap --with-ldap-sasl --with-mhash --with-mysql-sock=/run/mysqld/mysqld.sock"
|
export PHP_BUILD_CONFIGURE_OPTS="--with-libdir=lib --with-pear --with-ldap --with-ldap-sasl --with-mhash --with-sodium --with-gmp --with-mysql-sock=/run/mysqld/mysqld.sock"
|
||||||
export PHP_BUILD_KEEP_OBJECT_FILES=y
|
export PHP_BUILD_KEEP_OBJECT_FILES=y
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -76,11 +77,11 @@ if [ -z "$JENV_DISABLE" ] && [ -d "$JENV_ROOT/bin" ]; then
|
|||||||
eval "$(jenv init -)"
|
eval "$(jenv init -)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# nenv
|
# nodenv
|
||||||
NENV_ROOT="${NENV_ROOT:-${HOME}/.nenv}"
|
NODENV_ROOT="${NODENV_ROOT:-$HOME/.nodenv}"
|
||||||
if [ -z "$NENV_DISABLE" ] && [ -d "$NENV_ROOT/bin" ]; then
|
if [ -z "$NODENV_DISABLE" ] && [ -d "$NODENV_ROOT/bin" ]; then
|
||||||
export PATH="$HOME/.nenv/bin:$PATH"
|
export PATH="$HOME/.nodenv/bin:$PATH"
|
||||||
eval "$(nenv init -)"
|
eval "$(nodenv init -)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# pyenv
|
# pyenv
|
||||||
@@ -88,16 +89,22 @@ PYENV_ROOT="${PYENV_ROOT:-${HOME}/.pyenv}"
|
|||||||
if [ -z "$PYENV_DISABLE" ] && [ -d "$PYENV_ROOT/bin" ]; then
|
if [ -z "$PYENV_DISABLE" ] && [ -d "$PYENV_ROOT/bin" ]; then
|
||||||
export PATH="$HOME/.pyenv/bin:$PATH"
|
export PATH="$HOME/.pyenv/bin:$PATH"
|
||||||
export PIPENV_VENV_IN_PROJECT=1
|
export PIPENV_VENV_IN_PROJECT=1
|
||||||
PYENV_MAJOR_VERSION="$(pyenv --version|cut -f 2 -d ' '|cut -f 1 -d .)"
|
eval "$(pyenv init -)"
|
||||||
if [ "$PYENV_MAJOR_VERSION" -gt 1 ]; then
|
|
||||||
eval "$(pyenv init --path)"
|
|
||||||
fi
|
|
||||||
eval "$(pyenv init -|grep -v '^echo')"
|
|
||||||
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
|
||||||
|
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"
|
||||||
|
|||||||
@@ -1,7 +1,18 @@
|
|||||||
|
emulate bash
|
||||||
source /etc/profile
|
source /etc/profile
|
||||||
|
emulate zsh
|
||||||
|
|
||||||
source $HOME/.profile
|
source $HOME/.profile
|
||||||
|
|
||||||
# source kubernetes shell completion
|
# source kubernetes shell completion
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
@@ -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 '
|
||||||
|
|||||||
Reference in New Issue
Block a user