zshrc: run prettier

This commit is contained in:
Aminda Suomalainen 2024-07-14 16:34:10 +03:00
parent 345fe98f79
commit 16cc8855c7
Signed by: Mikaela
SSH Key Fingerprint: SHA256:CXLULpqNBdUKB6E6fLA1b/4SzG0HvKD19PbIePU175Q
1 changed files with 105 additions and 107 deletions

212
rc/zshrc
View File

@ -14,13 +14,13 @@ UNAME=$(uname)
#case $TERM in
# (*xterm* | *rxvt*)
# Write some info to terminal title.
# This is seen when the shell prompts for input.
# Write some info to terminal title.
# This is seen when the shell prompts for input.
# function precmd {
# print -Pn "\e]0;zsh%L %(1j,%j job%(2j|s|); ,)%~\a"
# }
# Write command and args to terminal title.
# This is seen while the shell waits for a command to complete.
# Write command and args to terminal title.
# This is seen while the shell waits for a command to complete.
# function preexec {
# printf "\033]0;%s\a" "$1"
# }
@ -30,9 +30,8 @@ UNAME=$(uname)
# enable terminal bell
if [[ -f /usr/bin/xset ]];
then
(xset b on&)
if [[ -f /usr/bin/xset ]]; then
(xset b on &)
fi
##### Defaults etc... M0TZLS #####
@ -94,10 +93,10 @@ zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
# Show the hostname, uptime and users logged in on shell start
if hash hostname 2>/dev/null; then
(hostname&)
if hash hostname 2> /dev/null; then
(hostname &)
fi
(uptime&)
(uptime &)
(echo "")
#if [[ $UNAME != Darwin ]] then;
@ -157,15 +156,15 @@ if [ -f ~/.zshenv ]; then
fi
# Enable core files.
(ulimit -c unlimited&)
(ulimit -c unlimited &)
# More colours
if [[ $TERM == 'xterm' ]]; then
export TERM=xterm-256color
export TERM=xterm-256color
fi
if [[ $TERM == 'screen' ]]; then
export TERM=screen-256color
export TERM=screen-256color
fi
# Sets the default editor.
@ -198,7 +197,7 @@ CPUARCH=$(uname -p)
if [ -f ~/.gnupg/sshcontrol ]; then
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent
gpg-connect-agent updatestartuptty /bye >/dev/null 2>&1
gpg-connect-agent updatestartuptty /bye > /dev/null 2>&1
# otherwise use the normal ssh-agent
else
# if the output is going to /dev/null, it's non/existence doesn't matter
@ -235,20 +234,20 @@ fi
# https://github.com/rbenv/rbenv
if [ -d ~/.rbenv/bin ]; then
PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
rbenv init >/dev/null 2>&1
rbenv init > /dev/null 2>&1
# Remember! And verify it before running!
# git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
fi
# Add RubyGems to PATH
if hash ruby 2>/dev/null; then
if hash ruby 2> /dev/null; then
PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"
fi
# https://github.com/pyenv/pyenv
if [ -d ~/.pyenv/bin ]; then
PATH="$HOME/.pyenv/bin:$PATH"
pyenv init >/dev/null 2>&1
pyenv init > /dev/null 2>&1
# Worth considering (and verifying before running)
# git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
# git clone https://github.com/pyenv/pyenv-virtualenvwrapper.git $(pyenv root)/plugins/pyenv-virtualenvwrapper
@ -274,7 +273,7 @@ alias sudo="\sudo --preserve-env=tmux"
alias ..="cd .."
# Use htop instead of top if available
if hash htop 2>/dev/null; then
if hash htop 2> /dev/null; then
alias top="htop"
fi
@ -378,7 +377,7 @@ alias rsync-folder="rsync -h --progress -azvv "
#fi
# Use GPG2 instead of GPG!
if hash gpg2 2>/dev/null; then
if hash gpg2 2> /dev/null; then
alias gpg=gpg2
export KEYBASE_GPG=gpg2
fi
@ -398,11 +397,11 @@ alias refreshgroups="exec su -l $USER"
alias ssh-pubkey-length="ssh-keygen -lf "
# MSDOS commands. MSDOS is after every alias line to get these lines easily by grepping.
alias cls=clear # MSDOS
alias help=man # MSDOS
alias cls=clear # MSDOS
alias help=man # MSDOS
alias ipconfig=ifconfig # MSDOS
alias copy=cp # MSDOS
alias move=mv # MSDOS
alias copy=cp # MSDOS
alias move=mv # MSDOS
# List git committers of repository
alias git-committers="git shortlog -s"
@ -508,7 +507,7 @@ alias venvpypy=pypyvenv
# cp/mv using rsync. rcp appears to be link to scp in my system, so I can
# safely use this alias.
if hash rsync 2>/dev/null; then
if hash rsync 2> /dev/null; then
alias rcp="rsync -a --progress"
alias rmv="rsync -a --progress --remove-source-files"
fi
@ -575,8 +574,7 @@ alias mpvm="mpv --no-video"
alias mpvms="mpv --no-video --shuffle"
# Compatibility with my i3 alsactl mess
if [ -f ~/.config/asound.state ]
then
if [ -f ~/.config/asound.state ]; then
alias alsactl="\alsactl -f ~/.config/asound.state"
fi
@ -594,14 +592,14 @@ alias chattr="\chattr -V"
alias chmod="\chmod --verbose"
# https://github.com/nodejs/corepack/blob/v0.28.2/README.md#corepack-enable--name
if hash corepack 2>/dev/null; then
if hash corepack 2> /dev/null; then
alias yarn="corepack yarn"
alias yarnpkg="corepack yarnpkg"
alias pnpm="corepack pnpm"
alias pnpx="corepack pnpx"
alias npm="corepack npm"
alias npx="corepack npx"
if ! hash prettier 2>/dev/null; then
if ! hash prettier 2> /dev/null; then
alias prettier="corepack pnpx prettier --cache --ignore-unknown"
fi
else
@ -612,7 +610,7 @@ fi
alias pn="corepack pnpm"
# github-pages etc.
if hash bundle 2>/dev/null; then
if hash bundle 2> /dev/null; then
alias jekyll="bundle exec jekyll"
fi
@ -645,33 +643,33 @@ function geoip() {
## for unit193 ;)
## use command "ex" to extract any archive files.
## "ex package.zip" for example
function ex ()
{
if [ -f "$1" ] ; then
case "$1" in
*.tar) tar xvf $1 ;;
*.tar.bz2 | *.tbz2 ) tar xjvf $1 ;;
*.tar.gz | *.tgz ) tar xzvf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*.xz) tar xJvf $1 ;;
*.deb)
DIR=${1%%_*.deb}
ar xv $1
mkdir ${DIR}
tar -C ${DIR} -xzvf data.tar.gz ;;
*.rpm) rpm2cpio $1 | cpio -vid ;;
*) echo ""${1}" cannot be extracted via extract()"
;;
esac
function ex() {
if [ -f "$1" ]; then
case "$1" in
*.tar) tar xvf $1 ;;
*.tar.bz2 | *.tbz2) tar xjvf $1 ;;
*.tar.gz | *.tgz) tar xzvf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*.xz) tar xJvf $1 ;;
*.deb)
DIR=${1%%_*.deb}
ar xv $1
mkdir ${DIR}
tar -C ${DIR} -xzvf data.tar.gz
;;
*.rpm) rpm2cpio $1 | cpio -vid ;;
*)
echo ""${1}" cannot be extracted via extract()"
;;
esac
else
echo ""${1}" is not a valid file"
fi
echo ""${1}" is not a valid file"
fi
}
# Given by nyuszika7h. Shortens GitHub URLs with git.io
@ -705,45 +703,45 @@ function gribble-gpg-everify() {
function shell-things {
export SHELL_THINGS_REPO=$HOME/.shell-things
export SHELL_THINGS_REPO=$HOME/.shell-things
# Check if ~/.shell-things exists and cd and pull.
if [ -d $SHELL_THINGS_REPO ]; then
echo "shell-things: $SHELL_THINGS_REPO exists, git pulling..."
echo ""
cd $SHELL_THINGS_REPO
git remote set-url origin https://gitea.blesmrt.net/Mikaela/shell-things.git
git fetch --all
git pull
git verify-commit HEAD
sleep 10
echo ""
echo "shell-things: Installing/Upgrading..."
echo ""
# If it doesn't exist...
else
echo ""
echo "shell-things: $SHELL_THINGS_REPO doesn't exist, cloning..."
echo ""
git clone https://gitea.blesmrt.net/Mikaela/shell-things.git $SHELL_THINGS_REPO
cd $SHELL_THINGS_REPO
sleep 10
echo ""
echo "shell-things: Installing/Upgrading..."
echo ""
fi
# Check if ~/.shell-things exists and cd and pull.
if [ -d $SHELL_THINGS_REPO ]; then
echo "shell-things: $SHELL_THINGS_REPO exists, git pulling..."
echo ""
cd $SHELL_THINGS_REPO
git remote set-url origin https://gitea.blesmrt.net/Mikaela/shell-things.git
git fetch --all
git pull
git verify-commit HEAD
sleep 10
echo ""
echo "shell-things: Installing/Upgrading..."
echo ""
# If it doesn't exist...
else
echo ""
echo "shell-things: $SHELL_THINGS_REPO doesn't exist, cloning..."
echo ""
git clone https://gitea.blesmrt.net/Mikaela/shell-things.git $SHELL_THINGS_REPO
cd $SHELL_THINGS_REPO
sleep 10
echo ""
echo "shell-things: Installing/Upgrading..."
echo ""
fi
# Installing...
bash -x ./install
echo ""
echo "shell-things: Installing finished."
echo ""
# Installing...
bash -x ./install
echo ""
echo "shell-things: Installing finished."
echo ""
echo ""
echo "shell-things: Everything is now done :)"
echo ""
echo ""
echo "shell-things: Everything is now done :)"
echo ""
cd
cd
}
@ -765,12 +763,12 @@ cd
# Use clang if installed. It seems interesting and this is probably good
# way to test it. This might not be a function, but I don't have any better
# place for this.
if hash clang 2>/dev/null; then
if hash clang 2> /dev/null; then
export CC=clang
export HOMEBREW_CC=clang
fi
if hash clang++ 2>/dev/null; then
if hash clang++ 2> /dev/null; then
export CXX=clang++
fi
@ -782,7 +780,7 @@ github-add-pulls() {
# Get server SSL certificate fingerprint in MD5, SHA1 and SHA256.
# Note that OpenSSL doesn't support IPv6 at time of writing (2015-01-13).
serversslcertfp () {
serversslcertfp() {
SSSLCFFN=$(openssl s_client -showcerts -connect $1 < /dev/null)
# To see all validity information
echo "$SSSLCFFN"
@ -795,7 +793,7 @@ serversslcertfp () {
}
# The same for local certificate file
sslcertfp () {
sslcertfp() {
cat $1 | openssl x509 -md5 -fingerprint -noout
cat $1 | openssl x509 -sha1 -fingerprint -noout
cat $1 | openssl x509 -sha256 -fingerprint -noout
@ -808,36 +806,36 @@ serversslciphers() {
}
# Generate SSL certificate
sslgenpem () {
sslgenpem() {
openssl req -nodes -newkey rsa:4096 -keyout $1.pem -x509 -days 3650 -out $1.pem -subj "/CN=$2"
}
# Managing SSL certificates of Google Chrome
chrome-add-cert () {
chrome-add-cert() {
echo "Please ensure that either libnss3-tools or nss-tools is installed."
certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n $1 -i $1
}
chrome-list-certs () {
chrome-list-certs() {
echo "Please ensure that either libnss3-tools or nss-tools is installed."
certutil -d sql:$HOME/.pki/nssdb -L # add '-h all' to see all built-in certs
}
ssldownloadcert () {
ssldownloadcert() {
echo "Please ensure that either libnss3-tools or nss-tools is installed."
echo QUIT | openssl s_client -connect $1:443 | sed -ne '/BEGIN CERT/,/END CERT/p' | tee $1.pem
}
# Getting magnet from transmission-daemon
transmission-torrents () {
transmission-torrents() {
transmission-remote -l
}
transmission-magnet () {
transmission-magnet() {
transmission-remote -l -t $1 -i | \grep magnet | awk -F': ' '{print $2}'
}
# Merges the last $1 commits into one
git-squash () {
git-squash() {
git reset --soft HEAD~$1
git commit
}
@ -849,8 +847,8 @@ mtrp() {
}
# My IPv4 address
myip4 () {
if hash dig 2>/dev/null; then
myip4() {
if hash dig 2> /dev/null; then
dig +short myip.opendns.com. A @208.67.222.222
else
curl -L4s https://icanhazip.com/
@ -858,8 +856,8 @@ myip4 () {
}
# My IPv6 address
myip6 () {
if hash dig 2>/dev/null; then
myip6() {
if hash dig 2> /dev/null; then
dig +short myip.opendns.com. AAAA @2620:0:ccc::2
else
curl -L6s https://icanhazip.com/
@ -869,13 +867,13 @@ myip6 () {
# Easier verifying of SSH signed files: ssh-verify-file whatever@mikaela.info file.txt
# It's assumed that signature of file.txt is called as file.txt.sig
sshAllowedSigners=$HOME/src/gitea.blesmrt.net/Mikaela/ssh-allowed_signers/allowed_signers
ssh-verify-file () {
ssh-verify-file() {
echo "$1 ${2:?Usage: ssh-verify-file <email> <file-to-verify>}" > /dev/null
ssh-keygen -Y verify -f $sshAllowedSigners -I $1 -n file -s $2.sig < $2
}
# I use nvim, while I keep running vim instead
if hash nvim 2>/dev/null; then
if hash nvim 2> /dev/null; then
vim() {
echo 'using nvim instead'
/usr/bin/env nvim "$@"