update
This commit is contained in:
@@ -142,6 +142,23 @@ UpdateAURPackages() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
################################################################################
|
||||
## My Personal Functions
|
||||
|
||||
|
||||
# copy last command
|
||||
_copy_last_command() {
|
||||
# Use `history -p !!` and capture only the second line
|
||||
local last_command=$(history -p !! | tail -n 1)
|
||||
|
||||
echo -n "${last_command}" | xclip -sel clip
|
||||
# copyq add "${last_command}"
|
||||
echo "Copied to copyQ, but not to clipboard"
|
||||
}
|
||||
|
||||
|
||||
|
||||
psyu() {
|
||||
# Updates all packages in the system.
|
||||
# Upstream (i.eUpdate. Arch) packages are updated first.
|
||||
@@ -206,23 +223,25 @@ bootwindows ()
|
||||
## FZF
|
||||
# https://github.com/junegunn/fzf/wiki/examples#opening-files
|
||||
fe() {
|
||||
IFS=$'\n' files=($(fzf-tmux --query="$1" --multi --select-1 --exit-0))
|
||||
[[ -n "$files" ]] && ${EDITOR:-vim} "${files[@]}"
|
||||
IFS=$'\n' files=($(fzf --query="$1" --multi --select-1 --exit-0))
|
||||
[[ -n "$files" ]] && zeditor "${files[@]}"
|
||||
}
|
||||
|
||||
## FZF
|
||||
|
||||
# Modified version where you can press
|
||||
# - CTRL-O to open with `open` command,
|
||||
# - CTRL-E or Enter key to open with the $EDITOR
|
||||
fo() {
|
||||
cd /home/$USER/
|
||||
# cd /home/$USER/
|
||||
IFS=$'\n' out=("$(fzf -e --query="$1" --exit-0 --expect=alt-e,alt-o,ctrl-o,ctrl-e,ctrl-p)")
|
||||
key=$(head -1 <<< "$out")
|
||||
file=$(head -2 <<< "$out" | tail -1)
|
||||
# echo "key1: $key"
|
||||
|
||||
if [ -n "$file" ]; then
|
||||
file=/home/$USER/${file}
|
||||
file=${PWD}/${file}
|
||||
echo file: $file
|
||||
case "$key" in
|
||||
*ctrl-p*) echo ${file} | xclip -sel c ;; # copy variable contents to clip
|
||||
*alt-o*) Directory="$(dirname "${file}")" ; dolphin "${Directory}";;
|
||||
@@ -239,15 +258,15 @@ fo() {
|
||||
# xdg-open $file
|
||||
|
||||
case "$FileExtension" in
|
||||
*txt*) subl ${file} ;;
|
||||
*conf*) subl ${file} ;;
|
||||
*sh*) subl ${file} ;;
|
||||
*py*) subl ${file} ;;
|
||||
# *txt*) subl ${file} ;;
|
||||
# *conf*) subl ${file} ;;
|
||||
# *sh*) subl ${file} ;;
|
||||
# *py*) subl ${file} ;;
|
||||
*jpg*) gimp ${file} & xdotool key Escape ;;
|
||||
*png*) gimp ${file} & xdotool key Escape ;;
|
||||
*) subl ${file} ;; # sublime everything else
|
||||
*) atuin history start -- "nvim ${file}" > /dev/null && nvim ${file} ;;
|
||||
esac ;;
|
||||
*) xdg-open $file ;;
|
||||
*) atuin history start -- "nvim ${file}" > /dev/null && nvim ${file} ;;
|
||||
esac
|
||||
# echo "$file"
|
||||
# echo "key2: $key"
|
||||
@@ -256,13 +275,13 @@ fo() {
|
||||
fi
|
||||
#sleep .5
|
||||
#xdotool key F3
|
||||
fo
|
||||
# fo
|
||||
}
|
||||
# Expand on this later
|
||||
|
||||
|
||||
foa() {
|
||||
cd /
|
||||
cd "$PWD"
|
||||
IFS=$'\n' out=("$(fzf -e --query="$1" --exit-0 --expect=alt-e,alt-o,ctrl-o,ctrl-e,ctrl-p)")
|
||||
key=$(head -1 <<< "$out")
|
||||
file=$(head -2 <<< "$out" | tail -1)
|
||||
@@ -286,13 +305,14 @@ foa() {
|
||||
# xdg-open $file
|
||||
|
||||
case "$FileExtension" in
|
||||
*txt*) subl ${file} ;;
|
||||
*conf*) subl ${file} ;;
|
||||
*sh*) subl ${file} ;;
|
||||
*py*) subl ${file} ;;
|
||||
# *txt*) subl ${file} ;;
|
||||
# *conf*) subl ${file} ;;
|
||||
# *sh*) subl ${file} ;;
|
||||
# *py*) subl ${file} ;;
|
||||
*jpg*) gimp ${file} & xdotool key Escape ;;
|
||||
*png*) gimp ${file} & xdotool key Escape ;;
|
||||
*) subl ${file} ;; # sublime everything else
|
||||
# *) subl ${file} ;; # sublime everything else
|
||||
*) zeditor -a ${file} ;; # zeditor everything else
|
||||
esac ;;
|
||||
*) xdg-open $file ;;
|
||||
esac
|
||||
@@ -303,7 +323,7 @@ foa() {
|
||||
fi
|
||||
#sleep .5
|
||||
#xdotool key F3
|
||||
fo
|
||||
# fo
|
||||
}
|
||||
|
||||
|
||||
@@ -373,51 +393,136 @@ parul(){
|
||||
|
||||
|
||||
update() {
|
||||
paru -Sy archlinux-keyring endeavouros-keyring --noconfirm --needed # update keyrings
|
||||
paru -Syu --noconfirm # update packages, no confirmation
|
||||
local status=0
|
||||
|
||||
# Skip clearing update cache if this is Flexo Server
|
||||
if [[ $(hostname) == "FLEXO" ]]; then
|
||||
echo "Skipping Clearing Update Cache"
|
||||
else
|
||||
echo "Clearing out Pacman Cache"
|
||||
echo clearing out $(sudo ls /var/cache/pacman/pkg/ | wc -l) packages in cache
|
||||
( echo "y"; echo "y" ) | paru -Sccd
|
||||
# (d) removes all orphaned packages that are no longer needed on your system
|
||||
|
||||
#
|
||||
|
||||
|
||||
# update keyrings
|
||||
paru -Sy $(pacman -Qq | grep keyring) --noconfirm --needed
|
||||
if [ $? -ne 0 ]; then
|
||||
status=1
|
||||
fi
|
||||
|
||||
# run PBS backup script in background if hostname does not contain "pease-int"
|
||||
if [[ ! "$(hostname)" == *"pease-int"* ]]; then
|
||||
$HOME/Syncthing/Scripts/bash/proxmox/PBS-backup-script.cz "manual" &
|
||||
fi
|
||||
|
||||
|
||||
# update packages, no confirmation
|
||||
paru -Syu --noconfirm
|
||||
if [ $? -ne 0 ]; then
|
||||
status=1
|
||||
fi
|
||||
|
||||
# # Skip clearing update cache if this is Flexo Server or if update had errors
|
||||
# if [[ $(hostname) == "FLEXO" || $status -eq 1 ]]; then
|
||||
# echo "Skipping Clearing Update Cache"
|
||||
# else
|
||||
# echo "Clearing out Pacman Cache"
|
||||
# echo clearing out $(sudo ls /var/cache/pacman/pkg/ | wc -l) packages in cache
|
||||
# ( echo "y"; echo "y" ) | paru -Sccd
|
||||
# if [ $? -ne 0 ]; then
|
||||
# status=1
|
||||
# fi
|
||||
# sudo rm -rf /var/cache/pacman/pkg/* # remove any straggler directories
|
||||
# # sudo rm -R /var/cache/pacman/pkg/ # removes any stuck stragglers
|
||||
# # (d) removes all orphaned packages that are no longer needed on your system
|
||||
# fi
|
||||
|
||||
# echo ""
|
||||
if command -v flatpak &> /dev/null; then
|
||||
echo "Updating Flatpak packages:"
|
||||
flatpak update -y
|
||||
if [ $? -ne 0 ]; then
|
||||
status=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -d "$HOME/Syncthing/Configurations/Pacman+Paru/" ]; then
|
||||
echo "Exporting pkglist to /Configurations"
|
||||
pacman -Qqe > $HOME/Syncthing/Configurations/Pacman+Paru/$(hostname)_pacmanpkglist.txt
|
||||
else
|
||||
echo "Skipping pkglist export. Config folder doesn't exist on this device."
|
||||
fi
|
||||
# if [ -d "$HOME/Syncthing/Configurations/Pacman+Paru/" ]; then
|
||||
# echo "Exporting pkglist to /Configurations"
|
||||
# pacman -Qqe > $HOME/Syncthing/Configurations/Pacman+Paru/$(hostname)_pacmanpkglist.txt
|
||||
# else
|
||||
# : echo "Skipping pkglist export. Config folder doesn't exist on this device."
|
||||
# fi
|
||||
|
||||
|
||||
# 1 liner
|
||||
# paru -Sy archlinux-keyring chaotic-keyring endeavouros-keyring --noconfirm --needed && paru -Syu --noconfirm && { [[ $(hostname) == "EOS-SERVER" ]] && echo "Skipping Clearing Update Cache" || (echo "Clearing out Pacman Cache" && echo clearing out $(sudo ls /var/cache/pacman/pkg/ | wc -l) packages in cache && ( echo "y"; echo "y" ) | paru -Scc); } && echo "updating arch mirrorlists" && eos-rankmirrors
|
||||
return $status
|
||||
}
|
||||
|
||||
|
||||
updatevm() {
|
||||
local status=0
|
||||
|
||||
# update keyrings
|
||||
sudo pacman -Sy archlinux-keyring --noconfirm --needed
|
||||
if [ $? -ne 0 ]; then
|
||||
status=1
|
||||
fi
|
||||
|
||||
# update packages, no confirmation
|
||||
sudo pacman -Syu --noconfirm
|
||||
if [ $? -ne 0 ]; then
|
||||
status=1
|
||||
fi
|
||||
|
||||
# echo "Clearing out Pacman Cache"
|
||||
echo clearing out $(sudo ls /var/cache/pacman/pkg/ | wc -l) packages in cache
|
||||
( echo "y"; echo "y" ) | sudo pacman -Sccd
|
||||
if [ $? -ne 0 ]; then
|
||||
status=1
|
||||
fi
|
||||
sudo rm -rf /var/cache/pacman/pkg/* # remove any straggler directories
|
||||
# sudo rm -R /var/cache/pacman/pkg/ # removes any stuck stragglers
|
||||
# (d) removes all orphaned packages that are no longer needed on your system
|
||||
|
||||
echo ""
|
||||
if command -v flatpak &> /dev/null; then
|
||||
echo "Updating Flatpak packages:"
|
||||
flatpak update -y
|
||||
if [ $? -ne 0 ]; then
|
||||
status=1
|
||||
fi
|
||||
fi
|
||||
|
||||
return $status
|
||||
}
|
||||
|
||||
|
||||
updatewr() {
|
||||
# Run the Update function
|
||||
update
|
||||
local update_status=$?
|
||||
|
||||
# Restart
|
||||
sudo reboot
|
||||
# Only reboot if update was successful
|
||||
if [ $update_status -eq 0 ]; then
|
||||
echo "Update completed successfully. Rebooting system..."
|
||||
sudo reboot
|
||||
else
|
||||
echo "Update encountered errors (exit code: $update_status). Skipping reboot."
|
||||
return $update_status
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
updatews() {
|
||||
# Run the Update function
|
||||
update
|
||||
local update_status=$?
|
||||
|
||||
# Restart
|
||||
sudo poweroff
|
||||
# run a pbs backup
|
||||
$HOME/Syncthing/Scripts/bash/proxmox/PBS-backup-script.cz manual
|
||||
|
||||
# Only reboot if update was successful
|
||||
if [ $update_status -eq 0 ]; then
|
||||
echo "Update completed successfully. Shutting down system..."
|
||||
sudo poweroff
|
||||
else
|
||||
echo "Update encountered errors (exit code: $update_status). Skipping poweroff."
|
||||
return $update_status
|
||||
fi
|
||||
}
|
||||
|
||||
rank() {
|
||||
@@ -426,14 +531,27 @@ rank() {
|
||||
}
|
||||
|
||||
rkeymapper(){
|
||||
sudo pkill keymapper
|
||||
sudo systemctl restart keymapperd & keymapper &
|
||||
echo "keymapper restarted successfully"
|
||||
while true; do
|
||||
sudo pkill keymapper
|
||||
sudo systemctl restart keymapperd & keymapper
|
||||
echo "keymapper restarted successfully"
|
||||
sleep 1 # Add a small delay to prevent excessive CPU usage
|
||||
done
|
||||
|
||||
# One Liner
|
||||
# sudo pkill keymapper ; sudo systemctl restart keymapperd & keymapper
|
||||
}
|
||||
|
||||
rteams(){
|
||||
pkill teams-for-linux
|
||||
sleep 1
|
||||
teams-for-linux
|
||||
}
|
||||
|
||||
|
||||
rntfy(){
|
||||
pgrep -f ntfy-Automate.sh | xargs kill
|
||||
$HOME//.config/scripts/ntfy-react/ntfy-react.sh &
|
||||
$HOME/Syncthing/Scripts/bash/ntfy-react/ntfy-react.sh &
|
||||
}
|
||||
|
||||
cdp(){
|
||||
@@ -467,7 +585,16 @@ export PATH="$HOME/.local/bin:$PATH"
|
||||
export PATH="$PATH:/opt/sublime_merge"
|
||||
export PATH="$PATH:~/.ssh/"
|
||||
|
||||
# default editor for Terminal
|
||||
export EDITOR=nvim
|
||||
alias vim='nvim'
|
||||
alias vi='nvim'
|
||||
alias n="nvim"
|
||||
if command -v nvim &> /dev/null; then
|
||||
alias nano="nvim"
|
||||
fi
|
||||
|
||||
#alias dump="zellij action dump-screen --full > /tmp/terminal-output-$(date +%Y%m%d_%H%M%S) && echo /tmp/terminal-output-$(date +%Y%m%d_%H%M%S) | xclip -sel clip && echo 'history dumped to file and filepath copied to clipboard.'"
|
||||
|
||||
# pacman/paru aliases
|
||||
# -------------------
|
||||
@@ -480,26 +607,50 @@ alias parur='paru -Rs'
|
||||
alias parurr='paru -Rs'
|
||||
alias parurl='sudo pacman -Syy'
|
||||
alias pcs='pacseek'
|
||||
alias mirror='eos-rankmirrors' # update mirrorlists
|
||||
|
||||
|
||||
# misc aliases
|
||||
# Misc aliases
|
||||
alias cda='cd $HOME/Syncthing/Git/ansible/' # cd into the ansible directory
|
||||
alias clc='_copy_last_command' # copy last run command to copyq clipboard
|
||||
alias cpc='_copy_last_command' # copy last run command to copyq clipboard
|
||||
alias ef='_open_files_for_editing' # 'ef' opens given file(s) for editing
|
||||
alias clip='xclip -sel clip' # output piped content to clipboard
|
||||
alias ntfythis='{ read contents; ntfy publish --title="From Terminal:" terminal-pipes "$contents"; }'
|
||||
alias snano='sudo nano'
|
||||
alias pu='pdfunite'
|
||||
alias tda='todo.sh add'
|
||||
alias yt='yt-dlp'
|
||||
alias chrome='chromium'
|
||||
alias mvideos='/home/yuriy/Syncthing/Python/Tools/MergeVideoFilesTogether.py'
|
||||
|
||||
#alias everything=fo
|
||||
alias todos='rg "(FIXME|TODO)" .' # search the contents of folders/subfolders for fixme,todo,
|
||||
alias ipb='ip -brief a'
|
||||
alias dol='dolphin'
|
||||
alias chmodx="chmod u+x" # make file executable for current user
|
||||
alias sm='smerge'
|
||||
alias smmt='smerge mergetool'
|
||||
# mouse jiggler
|
||||
alias ka="while :; do xdotool mousemove_relative -- $(( $RANDOM % 3 - 1 )) $(( $RANDOM % 3 - 1 )) sleep 60; done" # Keep screen awake
|
||||
alias z="zellij"
|
||||
alias za="zellij attach"
|
||||
|
||||
|
||||
|
||||
alias fuz="fuz --edit --names --max-depth 8"
|
||||
alias find='nvim $(tv)'
|
||||
|
||||
# Opencode nvim
|
||||
alias opcnv='opencode --port 4096'
|
||||
alias opcnvim='opencode --port 4096'
|
||||
|
||||
# ------------------------------------------------
|
||||
# SSH ALIASES
|
||||
# ------------------------------------------------
|
||||
alias ss='$HOME/Syncthing/Scripts/bash/fzf/fzf_ssh_picker.sh'
|
||||
|
||||
# boot/switch to CLI/GUI target
|
||||
alias switchtocli="sudo systemctl isolate multi-user.target"
|
||||
alias switchtogui="sudo systemctl isolate graphical.target"
|
||||
alias bootcli="sudo systemctl set-default multi-user.target"
|
||||
alias boottty="sudo systemctl set-default multi-user.target"
|
||||
alias bootgui="sudo systemctl set-default graphical.target"
|
||||
|
||||
|
||||
@@ -533,14 +684,28 @@ alias cza="chezmoi apply"
|
||||
alias czadd="chezmoi add"
|
||||
alias czc="chezmoi cd"
|
||||
alias czcd="chezmoi cd"
|
||||
alias czgpp="chezmoi cd ; git pull"
|
||||
alias czdiff="chezmoi diff"
|
||||
alias czd="dolphin $HOME/.local/share/chezmoi ; cd /home/yuriy/.local/share/chezmoi"
|
||||
alias czea="chezmoi edit --apply"
|
||||
alias czstatus="subl $HOME/.config/chezmoi/chezmoi-status"
|
||||
|
||||
# Misc
|
||||
alias ka="while :; do xdotool mousemove_relative -- $(( $RANDOM % 3 - 1 )) $(( $RANDOM % 3 - 1 )) sleep 60; done" # Keep screen awake
|
||||
alias chmodx="chmod u+x" # make file executable for current user
|
||||
|
||||
alias sm='smerge'
|
||||
|
||||
# Opencode
|
||||
alias opc="opencode"
|
||||
alias opcls="$HOME/Syncthing/Scripts/bash/fzf/fzf-opencode-session-picker.sh"
|
||||
|
||||
|
||||
# Syslog Helper
|
||||
alias syslog="$HOME/Syncthing/Scripts/bash/syslog-helper/get-syslog.sh"
|
||||
|
||||
# ------------------------------------------------
|
||||
# Work Related
|
||||
# ------------------------------------------------
|
||||
alias fw="$HOME/.ssh/forwards gui"
|
||||
# alias ansible-playbook="cd $/Syncthing/Git/ansible/"
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
@@ -595,3 +760,42 @@ fi
|
||||
if command -v starship &> /dev/null; then
|
||||
eval "$(starship init bash)"
|
||||
fi
|
||||
|
||||
# Initialize fuz if it's installed
|
||||
if command -v fuz &> /dev/null; then
|
||||
export FUZ_EDITOR=nvim
|
||||
# echo $FUZ_EDITOR
|
||||
alias fz="fuz --edit"
|
||||
fi
|
||||
|
||||
# Required: Path to OpenCode storage directory
|
||||
export OPENCODE_STORAGE_DIR="$HOME/.local/share/opencode/storage"
|
||||
|
||||
|
||||
if command -v zellij &> /dev/null; then
|
||||
if [[ -z "$ZELLIJ" ]]; then
|
||||
|
||||
# Get current terminal dimensions
|
||||
# cols=$(tput cols)
|
||||
lines=$(tput lines)
|
||||
echo $lines
|
||||
|
||||
# Define your "too small" threshold (adjust these values as needed)
|
||||
# For example, if it's smaller than 80 columns or 20 lines, skip Zellij
|
||||
if [[ "$lines" -lt 20 ]]; then
|
||||
echo "Terminal too small for Zellij. Skipping."
|
||||
else
|
||||
if [[ "$ZELLIJ_AUTO_ATTACH" == "true" ]]; then
|
||||
# cd ~/Syncthing/Git/ansible/
|
||||
zellij attach -c
|
||||
else
|
||||
# cd ~/Syncthing/Git/ansible/
|
||||
zellij
|
||||
fi
|
||||
|
||||
if [[ "$ZELLIJ_AUTO_EXIT" == "true" ]]; then
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user