Add dotfiles macos

This commit is contained in:
N0lik
2025-08-04 03:06:11 +04:00
parent 74bde09164
commit ffd414e1ff
6 changed files with 81 additions and 108 deletions

108
.bashrc
View File

@@ -1,108 +0,0 @@
# .bashrc
# COnfigure PS1 Begin
INPUT_COLOR="\[\033[0m\]"
DIR_COLOR="\[\033[0;33m\]"
DIR="\w"
LINE_VC="\342\224\200"
LINE_CN_1="\342\224\214"
LINE_CN_2="\342\224\224"
LINE_CR="\[\033[0;37m\]"
USER="\[\033[0;35m\]\u@"
HOST="\[\033[0;32m\]<\h>"
SYMBOL="\[\033[0;32m\]"
TEST="\[\033[0m\]>"
if [[ ${EUID} == 0 ]]; then
USER="\[\033[0;31m\]\u@"
HOST="\[\033[0;32m\]\h"
SYMBOL="\[\033[0;31m\]"
TEST="\[\033[0m\]>>"
fi
export PS1="$LINE_CR$LINE_CN_1$LINE_VC $USER$HOST $DIR_COLOR$DIR \n$LINE_CR$LINE_CN_2$LINE_VC $SYMBOL$TEST $INPUT_COLOR"
# Configure PS1 end
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]; then
PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
if [ -d ~/.bashrc.d ]; then
for rc in ~/.bashrc.d/*; do
if [ -f "$rc" ]; then
. "$rc"
fi
done
fi
unset rc
# My script
lori() {
local lori_name="${1}"
declare -A lori_list
lori_list=(
[dist_list]="df -h"
)
if [[ -z ${lori_list[$lori_name]} || -z "$lori_name" || "$lori_name" == "-h" ]]; then
echo "COMMANDS:"
printf "%-20s %s\n" "keys" "command"
echo "============================="
for key in "${!lori_list[@]}"; do
printf "%-20s %s\n" "$key" "${lori_list[$key]}"
done | sort
return 0
else
if [[ -n "$BASH" && -t 0 ]]; then
local command_to_insert="${lori_list[$lori_name]}"
bind '"\e[0n": "'"${command_to_insert}"'"'
printf '\e[5n'
else
echo "${lori_list[$lori_name]}"
fi
return 0
fi
}
_lori_completion() {
local curl prev opts
COMPREPLY=()
curl="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts=$(lori -h | awk 'NR>4 {print $1}')
if [[ ${curl} == * ]]; then
COMPREPLY=($(compgen -W "${opts}" -- ${curl}))
return 0
fi
}
complete -F _lori_completion lori
myalias() {
local RED=$(tput setaf 1)
local GREEN=$(tput setaf 2)
local normal=$(tput sgr0)
echo "My custom aliases:"
printf "%-20s %s\n" "Alias" "Command"
echo "------------------------------"
for key in $(cat ~/.dotfiles/alias/bash_aliases | awk '{print $2}' | awk -F"=" '{print $1}'); do
command=$(cat ~/.dotfiles/alias/bash_aliases | grep "${key}" | awk -F"=" '{print $2}')
printf "%-20s %s\n" "${RED}$key${normal}" "${GREEN}$command${normal}"
done | sort
return 0
}
complete -F myalias
# load bash alias
if [ -f ~/.dotfiles/bash_aliases ]; then
. ~/.dotfiles/.bash_aliases
fi

View File

81
macos/.zshrc Normal file
View File

@@ -0,0 +1,81 @@
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH
# Path to your Oh My Zsh installation.
export ZSH="$HOME/.oh-my-zsh"
export PATH=/opt/homebrew/bin:$PATH
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
export PATH=$HOME/.local/bin:$PATH
export EDITOR="/usr/bin/vim"
export ANSIBLE_CONFIG="$HOME/ansible/ansible.cfg"
export DOCKER_HOST=tcp://192.168.19.244:2376
export DOCKER_CERT_PATH="$HOME/.docker/cert-for-docker"
export DOCKER_TLS_VERIFY=1
ZSH_THEME="crunch"
plugins=(git docker vscode zsh-autosuggestions zsh-syntax-highlighting)
source $ZSH/oh-my-zsh.sh
if [[ -e $(which batcat) ]]; then
export bat="batcat"
alias bat="batcat"
elif [[ -e $(which bat) ]]; then
export bat="bat"
fi
if [[ -n $bat ]]; then
export COLORTERM="truecolor"
export BAT_THEME="Monokai Extended Origin"
export MANPAGER="sh -c 'col -bx | $bat --language=man --style=plain'"
export MANROFFOPT="-c"
alias cat="$bat --style=plain --paging=never"
alias less="$bat --paging=always"
if [[ $SHELL == *zsh ]]; then
alias -g -- --help='--help 2>&1 | $bat --language=help --style=plain'
fi
help() { "$@" --help 2>&1 | $bat --language=help --style=plain; }
tailf() { tail -f "$@" | $bat --paging=never --language=log; }
batdiff() { git diff --name-only --relative --diff-filter=d | xargs $bat --diff; }
fi
lori() {
local lori_name="${1}"
typeset -A lori_list
lori_list=(
disk_size "df -h"
)
if [[ -z ${lori_list[$lori_name]} || -z "$lori_name" || "$lori_name" == "-h" ]]; then
echo "AVAILABLE COMMANDS:\n"
printf "%-20s %s\n" "command"
echo "----------------------"
for key in "${(@k)lori_list}"; do
printf "%-20s %s\n" "$key" "${lori_list[$key]}"
done | sort
return 0
else
print -zr "${lori_list[$lori_name]}"
return 0
fi
}
_lori_completion() {
local -a keys
keys=($(lori -h | awk 'NR>4 {print $1}'))
compadd "$@" -- "${keys[@]}"
}
compdef _lori_completion lori
alias ..="cd .."
alias vm-manager="ssh -X root@10.10.0.254 virt-manager"
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
PRELINE="\r\033[A"
function color {
echo -e "\033]6;1;bg;red;brightness;$((1 + $RANDOM % 255))\a"$PRELINE
echo -e "\033]6;1;bg;green;brightness;$((1 + $RANDOM % 255))\a"$PRELINE
echo -e "\033]6;1;bg;blue;brightness;$((1 + $RANDOM % 255))\a"$PRELINE
}
color