mirror of
https://github.com/ivabus/dotfiles
synced 2024-11-23 08:35:08 +03:00
Update env
This commit is contained in:
parent
075d6f3c5c
commit
5fef083ba6
5 changed files with 107 additions and 35 deletions
92
env/.zshrc
vendored
92
env/.zshrc
vendored
|
@ -1,32 +1,74 @@
|
||||||
|
#!/bin/zsh
|
||||||
|
|
||||||
export ZSH="$HOME/.env/oh-my-zsh"
|
# Setup function, that resets terminal
|
||||||
|
|
||||||
ZSH_THEME="ivabus"
|
autoload -Uz add-zsh-hook
|
||||||
ENABLE_CORRECTION="true"
|
function reset_broken_terminal () {
|
||||||
plugins=(git zsh-syntax-highlighting)
|
printf '%b' '\e[0m\e(B\e)0\017\e[?5l\e7\e[0;0r\e8'
|
||||||
|
|
||||||
# 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"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
source $ZSH/oh-my-zsh.sh
|
export ZSH="$HOME/.dotfiles/zsh"
|
||||||
export REPORTTIME=10
|
|
||||||
|
# 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 vi="nvim"
|
||||||
alias vim="nvim"
|
alias vim="nvim"
|
||||||
|
alias ls="ls --color=always"
|
||||||
|
alias la="ls -la"
|
||||||
|
alias rh="rehash"
|
||||||
alias timestamp='date -u +%FT%TZ'
|
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
4
init
|
@ -5,5 +5,5 @@ then
|
||||||
echo "git should be installed"
|
echo "git should be installed"
|
||||||
exit 255
|
exit 255
|
||||||
fi
|
fi
|
||||||
git clone https://github.com/ivabus/ivabus-dotfiles $HOME/.dotfiles
|
git clone https://github.com/ivabus/dotfiles $HOME/.dotfiles
|
||||||
exec sh $HOME/.dotfiles/tools/install.sh
|
exec sh $HOME/.dotfiles/tools/install.sh < /dev/tty
|
||||||
|
|
3
init_env
Normal file
3
init_env
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
exec sh -c "$(curl https://raw.githubusercontent.com/ivabus/dotfiles/main/tools/env.sh)" < /dev/tty
|
34
tools/env.sh
34
tools/env.sh
|
@ -4,14 +4,31 @@ NC='\033[0m'
|
||||||
Green='\033[1;32m'
|
Green='\033[1;32m'
|
||||||
ARROW="${Green}=>${NC}"
|
ARROW="${Green}=>${NC}"
|
||||||
INPUT="${Green}::${NC}"
|
INPUT="${Green}::${NC}"
|
||||||
|
INSTALL_BIN_TOOLS="0"
|
||||||
|
HW_TARGET=$(uname)/$(uname -m)
|
||||||
|
|
||||||
echo "${ARROW} This script will create small environment"
|
case $HW_TARGET in
|
||||||
echo " with dotfiles from ivabus/ivabus-dotfiles"
|
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"
|
echo "${INPUT} Press enter to continue"
|
||||||
read
|
read
|
||||||
|
|
||||||
|
if [ $INSTALL_BIN_TOOLS = "1" ]
|
||||||
|
then
|
||||||
echo "${ARROW} Installing env to ~/.env"
|
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_PREFIX=~/.env/tea
|
||||||
TEA=~/.env/tea/tea.xyz/v0/bin/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"
|
PATH="$HOME/.env/bin:$PATH"
|
||||||
|
|
||||||
echo "${ARROW} Installing tea"
|
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"
|
echo "${ARROW} Installing neovim"
|
||||||
$TEA +neovim.io zsh -c "exit"
|
$TEA +neovim.io zsh -c "exit"
|
||||||
|
@ -60,13 +77,18 @@ do
|
||||||
ln -s $TEA ~/.env/bin/$i
|
ln -s $TEA ~/.env/bin/$i
|
||||||
done
|
done
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
echo "${ARROW} Installing dotfiles"
|
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
|
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
|
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
|
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
|
sh ~/.env/dotfiles/tools/link_env.sh
|
||||||
|
|
||||||
echo "${ARROW} Environment installed to ~/.env"
|
echo "${ARROW} Environment installed to ~/.env"
|
||||||
|
if [ $INSTALL_BIN_TOOLS = "1" ]
|
||||||
|
then
|
||||||
echo " To start environment just type:"
|
echo " To start environment just type:"
|
||||||
echo " PATH=\"\$HOME/.env/bin:\$PATH\" zsh"
|
echo " PATH=\"\$HOME/.env/bin:\$PATH\" zsh"
|
||||||
|
fi
|
|
@ -1,11 +1,16 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
echo "=> Linking zshrc"
|
|
||||||
|
NC='\033[0m'
|
||||||
|
Green='\033[1;32m'
|
||||||
|
ARROW="${Green}=>${NC}"
|
||||||
|
|
||||||
|
echo "$ARROW Linking zshrc"
|
||||||
if [ -f ~/.zshrc ]; then
|
if [ -f ~/.zshrc ]; then
|
||||||
echo "=> Moving old zshrc to ~/.zshrc.old"
|
echo "=> Moving old zshrc to ~/.zshrc.old"
|
||||||
mv ~/.zshrc ~/.zshrc.old
|
mv ~/.zshrc ~/.zshrc.old
|
||||||
fi
|
fi
|
||||||
ln -s ~/.env/dotfiles/env/.zshrc ~/.zshrc
|
ln -s ~/.env/dotfiles/env/.zshrc ~/.zshrc
|
||||||
echo "=> Linking neovim files"
|
echo "$ARROW Linking neovim files"
|
||||||
rm -rf ${XDG_CONFIG_HOME:-$HOME/.config}/nvim
|
rm -rf ${XDG_CONFIG_HOME:-$HOME/.config}/nvim
|
||||||
ln -s ~/.env/dotfiles/nvim ${XDG_CONFIG_HOME:-$HOME/.config}/nvim
|
ln -s ~/.env/dotfiles/nvim ${XDG_CONFIG_HOME:-$HOME/.config}/nvim
|
||||||
|
|
Loading…
Reference in a new issue