Update env

This commit is contained in:
Ivan Bushchik 2023-06-25 15:32:30 +03:00
parent 075d6f3c5c
commit 5fef083ba6
No known key found for this signature in database
GPG key ID: 9F6DDABE11A2674D
5 changed files with 107 additions and 35 deletions

92
env/.zshrc vendored
View file

@ -1,32 +1,74 @@
#!/bin/zsh
export ZSH="$HOME/.env/oh-my-zsh"
# Setup function, that resets terminal
ZSH_THEME="ivabus"
ENABLE_CORRECTION="true"
plugins=(git zsh-syntax-highlighting)
# Function to quickly show stats on systemload, usage of filesystems, usage of ram/swap and uptime
stats () {
AVLD=$(cut -d " " -f1-3 /proc/loadavg)
USEDMEM=$(free -h | grep Mem | awk '{print $3 " / " $2}')
USEDSWAP=$(free -h | grep Swap | awk '{ print $3 " / " $2}')
USEDSTRG=$(df / -h | tail -n 1 | awk '{print $3}')
USEDSTRGPERC=$(df / -h | tail -n 1 | awk '{print $5}')
STRG=$(df / -h | tail -n 1 | awk '{print $2}')
USEDSTRGHOME=$(df /home -h | tail -n 1 | awk '{print $3}')
USEDSTRGPERCHOME=$(df /home -h | tail -n 1 | awk '{print $5}')
STRGHOME=$(df /home -h | tail -n 1 | awk '{print $2}')
UPTIME=$(uptime -p)
printf "\e[0;34msystem load:\e[m\t${AVLD}\n"
printf "\e[0;34musage of /:\e[m\t${USEDSTRGPERC}% (${USEDSTRG}/${STRG})\n"
printf "\e[0;34musage of /home:\e[m\t${USEDSTRGPERCHOME}% (${USEDSTRGHOME}/${STRGHOME})\n"
printf "\e[0;34mmemory usage:\e[m\t${USEDMEM}\n"
printf "\e[0;34mswap usage:\e[m\t${USEDSWAP}\n"
printf "\e[0;34muptime:\e[m\t\t${UPTIME}\n"
autoload -Uz add-zsh-hook
function reset_broken_terminal () {
printf '%b' '\e[0m\e(B\e)0\017\e[?5l\e7\e[0;0r\e8'
}
source $ZSH/oh-my-zsh.sh
export REPORTTIME=10
export ZSH="$HOME/.dotfiles/zsh"
# Setup history
HISTFILE="$HOME/.zsh_history"
HISTSIZE=10000
SAVEHIST=10000
bindkey '\e[A' history-search-backward
bindkey '\e[B' history-search-forward
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_FIND_NO_DUPS
setopt EXTENDED_HISTORY
setopt INC_APPEND_HISTORY
setopt SHARE_HISTORY
setopt APPEND_HISTORY
setopt HIST_NO_STORE
REPORTTIME=3
autoload -Uz compinit bracketed-paste-magic url-quote-magic
compinit
zle -N bracketed-paste bracketed-paste-magic
zle -N self-insert url-quote-magic
zstyle ':completion:*' menu select
# Source section
source $HOME/.profile
source $ZSH/themes/ivabus.zsh-theme
source $ZSH/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# Alias section
alias vi="nvim"
alias vim="nvim"
alias ls="ls --color=always"
alias la="ls -la"
alias rh="rehash"
alias timestamp='date -u +%FT%TZ'
alias yt-dlp-opus="yt-dlp -f 251 -x"
alias jekyll_export="jekyll b -d ./_archive && cd _archive && tar cf ../site.tar ./ && cd .. && gzip -9 -f site.tar && rm -rf _archive"
# ffmpeg section
# Usage: ffmpeg_convert <output codec (hevc or h264)> <video_in> <video_out> [<quality (1 to 100)>]
ffmpeg_convert() {
ffmpeg -i $2 -c:v ${1}_videotoolbox $(if [ ! -z $4 ]; then echo "-q:v $4"; fi ) $3
}
# Usage: ffmpeg_telegram_video_sticker: <video_in> <time <= 3> [<chromakey color in hex>] [<chromakey similarity>]
ffmpeg_telegram_video_sticker() {
PWD_START=$(pwd)
TMPDIR=/tmp/sticker-$(date +%Y-%m-%d-%H:%M:%S)
mkdir $TMPDIR
cp $1 $TMPDIR/
cd $TMPDIR
ffmpeg -i $1 $(if [[ ! -z $3 && ! -z $4 ]]; then echo -vf "chromakey=\#$3:$4:0"; fi) -c copy -c:v png -t $2 tmp.mov
ffmpeg -y -i tmp.mov -r 30 -t $2 -an -c:v libvpx-vp9 -pix_fmt yuva420p -vf 'scale=512:512:force_original_aspect_ratio=decrease' -b:v 400K ${1}_sticker.webm
cp ${1}_sticker.webm $PWD_START/
cd $PWD_START
#rm -rf $TMP_DIR
}
test -d "$HOME/.env/tea" && source <("$HOME/.env/tea/tea.xyz/v*/bin/tea" --magic=zsh --silent)

4
init
View file

@ -5,5 +5,5 @@ then
echo "git should be installed"
exit 255
fi
git clone https://github.com/ivabus/ivabus-dotfiles $HOME/.dotfiles
exec sh $HOME/.dotfiles/tools/install.sh
git clone https://github.com/ivabus/dotfiles $HOME/.dotfiles
exec sh $HOME/.dotfiles/tools/install.sh < /dev/tty

3
init_env Normal file
View file

@ -0,0 +1,3 @@
#!/bin/sh
exec sh -c "$(curl https://raw.githubusercontent.com/ivabus/dotfiles/main/tools/env.sh)" < /dev/tty

View file

@ -4,14 +4,31 @@ NC='\033[0m'
Green='\033[1;32m'
ARROW="${Green}=>${NC}"
INPUT="${Green}::${NC}"
INSTALL_BIN_TOOLS="0"
HW_TARGET=$(uname)/$(uname -m)
echo "${ARROW} This script will create small environment"
echo " with dotfiles from ivabus/ivabus-dotfiles"
case $HW_TARGET in
Darwin/arm64)
INSTALL_BIN_TOOLS="1";;
Darwin/x86_64)
INSTALL_BIN_TOOLS="1";;
Linux/arm64|Linux/aarch64)
INSTALL_BIN_TOOLS="1";;
Linux/x86_64)
INSTALL_BIN_TOOLS="1";;
*)
INSTALL_BIN_TOOLS="0"
esac
echo "${ARROW} This script will create environment"
echo " with dotfiles from ivabus/dotfiles"
echo "${INPUT} Press enter to continue"
read
if [ $INSTALL_BIN_TOOLS = "1" ]
then
echo "${ARROW} Installing env to ~/.env"
mkdir -p ~/.env/bin > /dev/null 2>&1
mkdir ~/.env ~/.env/bin > /dev/null 2>&1
TEA_PREFIX=~/.env/tea
TEA=~/.env/tea/tea.xyz/v0/bin/tea
@ -22,7 +39,7 @@ sh -c "$(curl -fsSL https://raw.githubusercontent.com/romkatv/zsh-bin/master/ins
PATH="$HOME/.env/bin:$PATH"
echo "${ARROW} Installing tea"
zsh -c "sh <(curl https://tea.xyz) --prefix $TEA_PREFIX"
zsh -c "sh <(curl https://tea.xyz) -y --prefix $TEA_PREFIX"
echo "${ARROW} Installing neovim"
$TEA +neovim.io zsh -c "exit"
@ -60,13 +77,18 @@ do
ln -s $TEA ~/.env/bin/$i
done
fi
echo "${ARROW} Installing dotfiles"
git clone https://github.com/ivabus/ivabus-dotfiles ~/.env/dotfiles
$TEA git clone https://github.com/ivabus/dotfiles ~/.env/dotfiles
ZSH="$HOME/.env/oh-my-zsh" sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended > /dev/null 2>&1
curl -fsSL https://raw.githubusercontent.com/ivabus/ivabus-zsh-theme/master/ivabus.zsh-theme -o $HOME/.env/oh-my-zsh/custom/themes/ivabus.zsh-theme > /dev/null 2>&1
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $HOME/.env/oh-my-zsh/custom/plugins/zsh-syntax-highlighting > /dev/null 2>&1
sh ~/.env/dotfiles/tools/link_env.sh
echo "${ARROW} Environment installed to ~/.env"
if [ $INSTALL_BIN_TOOLS = "1" ]
then
echo " To start environment just type:"
echo " PATH=\"\$HOME/.env/bin:\$PATH\" zsh"
echo " PATH=\"\$HOME/.env/bin:\$PATH\" zsh"
fi

View file

@ -1,11 +1,16 @@
#!/bin/sh
set -e
echo "=> Linking zshrc"
NC='\033[0m'
Green='\033[1;32m'
ARROW="${Green}=>${NC}"
echo "$ARROW Linking zshrc"
if [ -f ~/.zshrc ]; then
echo "=> Moving old zshrc to ~/.zshrc.old"
mv ~/.zshrc ~/.zshrc.old
fi
ln -s ~/.env/dotfiles/env/.zshrc ~/.zshrc
echo "=> Linking neovim files"
echo "$ARROW Linking neovim files"
rm -rf ${XDG_CONFIG_HOME:-$HOME/.config}/nvim
ln -s ~/.env/dotfiles/nvim ${XDG_CONFIG_HOME:-$HOME/.config}/nvim