mirror of
https://github.com/sebaschi/dotfiles.git
synced 2025-11-08 23:54:29 +01:00
New aliases
This commit is contained in:
parent
14dfa6a57e
commit
b95d071caa
@ -1,25 +1,3 @@
|
||||
# User specific aliases and functions
|
||||
alias cdpex='cd ~/Documents/Education/UniBas/FS23/pids23/exercises/pids_2023/exercises/'
|
||||
alias uni23='cd ~/Nextcloud/Documents/Unibas/HS23/'
|
||||
alias thoc='cd ~/Nextcloud/Documents/Unibas/FS23/thoc/'
|
||||
alias inetsec='cd ~/Nextcloud/Documents/Unibas/FS23/inetsec/'
|
||||
#cd into os alias
|
||||
alias os='cd ~/Nextcloud/Documents/Unibas/FS23/os/'
|
||||
alias pkvps='cd ~/Nextcloud/Documents/Unibas/FS23/pkvps/'
|
||||
alias pids='cd ~/Nextcloud/Documents/Unibas/FS23/pids/'
|
||||
alias pr23='cd ~/Documents/Education/UniBas/HS23/pr23/'
|
||||
alias db23='cd ~/Documents/Education/UniBas/HS23/databases/'
|
||||
alias pet23='cd ~/Documents/Education/UniBas/HS23/pethpc23/'
|
||||
alias diskmath='cd ~/Documents/Education/UniBas/HS23/diskmath-tutorat23/'
|
||||
alias pullbooks='rsync -av ~/Nextcloud/Books/ ~/Books'
|
||||
alias pushbooks='rsync -av ~/Books/ ~/Nextcloud/Books'
|
||||
alias pushfs24='rsync -uav --exclude=".*" --exclude="__*" --exclude="/venv" ~/documents/education/unibas/fs24/ ~/Nextcloud/Documents/Unibas/FS24'
|
||||
alias pullfs24='rsync -uav --exclude=".*" ~/Nextcloud/Documents/Unibas/FS24/ ~/documents/education/unibas/fs24'
|
||||
alias fs24l='cd ~/documents/education/unibas/fs24'
|
||||
alias fs24c='cd ~/Nextcloud/Documents/Unibas/FS24'
|
||||
alias sdev='ssh sebl@slenzlinger.dev'
|
||||
alias sslenz='ssh fm18b_sebaschi@slenzlinger.ch'
|
||||
|
||||
#
|
||||
# eza aliases
|
||||
#
|
||||
@ -36,18 +14,48 @@ alias l='eza -CF'
|
||||
alias g='git'
|
||||
alias gs='git status'
|
||||
alias ga='git add'
|
||||
alias gaa='git add --all'
|
||||
|
||||
alias gc='git commit'
|
||||
alias gcm='git commit -m'
|
||||
alias gca='git commit --amend'
|
||||
|
||||
alias gco='git checkout'
|
||||
alias gcb='git checkout -b'
|
||||
|
||||
alias gcp='git cherry-pick'
|
||||
alias gcl='git clone'
|
||||
alias gpr='git pull --rebase'
|
||||
|
||||
alias gplr='git pull --rebase'
|
||||
alias gpl='git pull'
|
||||
alias gpo='git push origin'
|
||||
alias gpf='git push --force'
|
||||
alias gpl='git pull'
|
||||
# git log aliases
|
||||
alias glog='git log --oneline --graph --decorate'
|
||||
alias gloga='git log --oneline --graph --decorate --all'
|
||||
alias glod='git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'
|
||||
alias glods='git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short'
|
||||
alias glod='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset"'
|
||||
alias glods='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset" --date=short'
|
||||
|
||||
#termbin
|
||||
alias tb='nc termbin.com 9999'
|
||||
|
||||
# get error messages from journalctl
|
||||
alias jerr='journalctl -p 3 -xb'
|
||||
# get warning messages from journalctl
|
||||
alias jwarn='journalctl -p 4 -xb'
|
||||
# get critical messages from journalctl
|
||||
alias jcrit='journalctl -p 2 -xb'
|
||||
# get emergency messages from journalctl
|
||||
alias jemerg='journalctl -p 0 -xb'
|
||||
|
||||
# get status of all services
|
||||
alias jstat='systemctl list-units --type=service --state=running'
|
||||
# get status with failed services
|
||||
alias jstatf='systemctl list-units --type=service --state=failed'
|
||||
|
||||
# history
|
||||
alias histg='history | grep'
|
||||
|
||||
# get my ip
|
||||
alias myip='curl ifconfig.me'
|
||||
#TODO: get my ipv4
|
||||
|
||||
51
bash/bash_functions
Normal file
51
bash/bash_functions
Normal file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
### ARCHIVE EXTRACTION
|
||||
# usage: ex <file>
|
||||
function ex {
|
||||
if [ -z "$1" ]; then
|
||||
# display usage if no parameters given
|
||||
echo "Usage: ex <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
|
||||
echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
|
||||
else
|
||||
for n in "$@"
|
||||
do
|
||||
if [ -f "$n" ] ; then
|
||||
case "${n%,}" in
|
||||
*.cbt|*.tar.bz2|*.tar.gz|*.tar.xz|*.tbz2|*.tgz|*.txz|*.tar)
|
||||
tar xvf "$n" ;;
|
||||
*.lzma) unlzma ./"$n" ;;
|
||||
*.bz2) bunzip2 ./"$n" ;;
|
||||
*.cbr|*.rar) unrar x -ad ./"$n" ;;
|
||||
*.gz) gunzip ./"$n" ;;
|
||||
*.cbz|*.epub|*.zip) unzip ./"$n" ;;
|
||||
*.z) uncompress ./"$n" ;;
|
||||
*.7z|*.arj|*.cab|*.cb7|*.chm|*.deb|*.dmg|*.iso|*.lzh|*.msi|*.pkg|*.rpm|*.udf|*.wim|*.xar)
|
||||
7z x ./"$n" ;;
|
||||
*.xz) unxz ./"$n" ;;
|
||||
*.exe) cabextract ./"$n" ;;
|
||||
*.cpio) cpio -id < ./"$n" ;;
|
||||
*.cba|*.ace) unace x ./"$n" ;;
|
||||
*)
|
||||
echo "ex: '$n' - unknown archive method"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "'$n' - file does not exist"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function ensure {
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: ensure <command>"
|
||||
else
|
||||
if ! command -v $1 &> /dev/null
|
||||
then
|
||||
echo "$1 could not be found"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -26,7 +26,9 @@ fi
|
||||
|
||||
unset rc
|
||||
|
||||
source /home/slnopriv/alacritty/extra/completions/alacritty.bash
|
||||
if ! source /home/slnopriv/alacritty/extra/completions/alacritty.bash; then
|
||||
echo "Failed to source alacritty completions"
|
||||
fi
|
||||
eval "$(starship init bash)"
|
||||
|
||||
# >>> conda initialize >>>
|
||||
@ -45,7 +47,12 @@ unset __conda_setup
|
||||
# <<< conda initialize <<<
|
||||
#Source aliases
|
||||
source ~/.bash_aliases
|
||||
source ~/.fedora_aliases
|
||||
export PATH="~/scripts:$PATH"
|
||||
# Souecw functions
|
||||
source ~/.bash_functions
|
||||
|
||||
|
||||
# !! Contents within this block are managed by juliaup !!
|
||||
|
||||
case ":$PATH:" in
|
||||
|
||||
38
bash/fedora_aliases
Normal file
38
bash/fedora_aliases
Normal file
@ -0,0 +1,38 @@
|
||||
alias dnfs='dnf search'
|
||||
alias dnfl='dnf list'
|
||||
alias dnfli='dnf list installed'
|
||||
|
||||
# Using sudo
|
||||
alias dnfu='sudo dnf upgrade'
|
||||
alias dnfi='sudo dnf install'
|
||||
alias dnfr='sudo dnf remove'
|
||||
|
||||
# User specific aliases and functions
|
||||
alias cdpex='cd ~/Documents/Education/UniBas/FS23/pids23/exercises/pids_2023/exercises/'
|
||||
alias uni23='cd ~/Nextcloud/Documents/Unibas/HS23/'
|
||||
alias thoc='cd ~/Nextcloud/Documents/Unibas/FS23/thoc/'
|
||||
alias inetsec='cd ~/Nextcloud/Documents/Unibas/FS23/inetsec/'
|
||||
#cd into os alias
|
||||
alias os='cd ~/Nextcloud/Documents/Unibas/FS23/os/'
|
||||
alias pkvps='cd ~/Nextcloud/Documents/Unibas/FS23/pkvps/'
|
||||
alias pids='cd ~/Nextcloud/Documents/Unibas/FS23/pids/'
|
||||
alias pr23='cd ~/Documents/Education/UniBas/HS23/pr23/'
|
||||
alias db23='cd ~/Documents/Education/UniBas/HS23/databases/'
|
||||
alias pet23='cd ~/Documents/Education/UniBas/HS23/pethpc23/'
|
||||
alias diskmath='cd ~/Documents/Education/UniBas/HS23/diskmath-tutorat23/'
|
||||
alias pullbooks='rsync -av ~/Nextcloud/Books/ ~/Books'
|
||||
alias pushbooks='rsync -av ~/Books/ ~/Nextcloud/Books'
|
||||
alias pushfs24='rsync -uav --exclude=".*" --exclude="__*" --exclude="/venv" ~/documents/education/unibas/fs24/ ~/Nextcloud/Documents/Unibas/FS24'
|
||||
alias pullfs24='rsync -uav --exclude=".*" ~/Nextcloud/Documents/Unibas/FS24/ ~/documents/education/unibas/fs24'
|
||||
alias fs24l='cd ~/documents/education/unibas/fs24'
|
||||
alias fs24c='cd ~/Nextcloud/Documents/Unibas/FS24'
|
||||
alias sdev='ssh sebl@slenzlinger.dev'
|
||||
alias sslenz='ssh fm18b_sebaschi@slenzlinger.ch'
|
||||
|
||||
alias ccat='pygmentize -g'
|
||||
|
||||
# list repo IDs and which .repo they belong to
|
||||
alias frepos='grep -E "^\[.*]" /etc/yum.repos.d/*'
|
||||
|
||||
# grep aliases
|
||||
alias galias='alias | grep'
|
||||
19
bash/scripts/scripts/arrange_slides
Executable file
19
bash/scripts/scripts/arrange_slides
Executable file
@ -0,0 +1,19 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
filename=$1
|
||||
rmpattern=$2
|
||||
suffix=$3
|
||||
dstFolder="${PWD}/arranged"
|
||||
newFilename="${filename%${rmpattern}}${suffix}.pdf"
|
||||
# Make destination folder
|
||||
mkdir -p ${dstFolder}
|
||||
|
||||
pdfjam --nup 2x2 \
|
||||
--landscape \
|
||||
--clip 'true' \
|
||||
--delta '0cm 0cm' \
|
||||
--offset '1cm 0cm' \
|
||||
--outfile ${newFilename} ${filename}
|
||||
mv ${newFilename} ${dstFolder}
|
||||
# unused
|
||||
# --trim '0.7cm 0cm 0.7cm 0cm' \
|
||||
13
bash/scripts/scripts/arrangefai
Executable file
13
bash/scripts/scripts/arrangefai
Executable file
@ -0,0 +1,13 @@
|
||||
#! /usr/bin/env bash
|
||||
file=$1
|
||||
outfile="${file%'handout.pdf'}jam4.pdf"
|
||||
dst=${PWD}/jammed
|
||||
mkdir -p ${dst}
|
||||
pdfjam --nup 2x2 --column false \
|
||||
--landscape --offset '1.2cm 0cm' \
|
||||
--outfile ${outfile} --scale 0.95 \
|
||||
--frame true \
|
||||
$1
|
||||
|
||||
mv ${outfile} ${dst}
|
||||
|
||||
195
bash/scripts/scripts/chatroom
Executable file
195
bash/scripts/scripts/chatroom
Executable file
@ -0,0 +1,195 @@
|
||||
#!/usr/bin/env bash
|
||||
################################################################################
|
||||
## Author: Sebastian Lenzlinger
|
||||
## EMail: eswer@eswo.ch
|
||||
################################################################################
|
||||
|
||||
################################################################################
|
||||
# TIPP: source this file so functions are available directly in the command line
|
||||
################################################################################
|
||||
initialize () {
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: initialize '<name>'"
|
||||
echo "Please only supply your name as a single string"
|
||||
echo "This will be used as the branch name."
|
||||
return
|
||||
fi
|
||||
|
||||
usrnm=$1
|
||||
|
||||
|
||||
# Create repo 'usrnm' with branch 'usrnm'
|
||||
git init -b "${usrnm}" "${usrnm}" && cd "${usrnm}"
|
||||
echo "Initialized git repo ${usrnm} with branch ${usrnm}"
|
||||
git config --local user.name "${usrnm}"
|
||||
git config --local user.email "${usrnm}@gitchat.local"
|
||||
# Establish tree object
|
||||
treeroot=$(git write-tree)
|
||||
echo "Tree written at ref "${treeroot}"."
|
||||
|
||||
# Create initial commit without parent commits
|
||||
initcommit="$(echo "${usrnm} has joined the chatroom." | git commit-tree "${treeroot}")"
|
||||
echo "Initial commit "${initcommit}" with message "$(git cat-file -p ${initcommit})"."
|
||||
|
||||
#Set HEAD of usrnm branch to first commit
|
||||
git update-ref "$(git symbolic-ref HEAD)" "${initcommit}"
|
||||
}
|
||||
|
||||
|
||||
post() {
|
||||
if ! [[ -d "${PWD}/.git" ]]; then
|
||||
echo "You must be in a git repo root to use this command!"
|
||||
return
|
||||
fi
|
||||
|
||||
# Single quotes so can use any spacial characters that bash would expand.
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Please supply you message in single quotes!"
|
||||
echo "Usage: post '<msg>'"
|
||||
return
|
||||
fi
|
||||
|
||||
msg=$1
|
||||
|
||||
# this seems to be the way; assuming there is one tree
|
||||
roottreeref=$(git log --pretty=format:%T -n 1)
|
||||
if [[ -z "${roottreeref}" ]]; then
|
||||
echo "NO TREE: Couldnt find tree object."
|
||||
return
|
||||
fi
|
||||
echo "Root trees ref "${roottreeref}""
|
||||
|
||||
parents=
|
||||
for p in $(git for-each-ref --format='%(objectname)' refs/heads/); do
|
||||
parents+="-p ${p} "
|
||||
done
|
||||
echo "Parent commits ${parents}"
|
||||
|
||||
# This didn't work!!!
|
||||
# roottreeref=($(git cat-file --batch-all-objects --batch-check | grep tree))
|
||||
|
||||
# Put message at end so last whitespace is ignored, doesn't lead to issues
|
||||
commitref="$(git commit-tree ${roottreeref} ${parents} -m "${msg}")"
|
||||
echo "Current commits ref ${commitref}"
|
||||
|
||||
git update-ref "$(git symbolic-ref HEAD)" "${commitref}"
|
||||
echo
|
||||
echo "Posted message:"
|
||||
echo "${msg}"
|
||||
|
||||
unset roottreeref
|
||||
unset parents
|
||||
unset commitref
|
||||
unset msg
|
||||
}
|
||||
|
||||
show() {
|
||||
|
||||
if ! [[ -d "${PWD}/.git" ]]; then
|
||||
echo "You must be in a git repo root to use this command!"
|
||||
return
|
||||
fi
|
||||
|
||||
# This is not correct, only follow local branches, not remote branches.
|
||||
#for b in $(git branch --format '%(refname:short)'); do
|
||||
#git log $b --pretty=format:'%C(bold)%an (%ar):%C(reset) %s' --reverse
|
||||
#done
|
||||
if [[ $# -gt 1 ]];then
|
||||
echo "There is only one OPTIONAL argument: -g"
|
||||
return
|
||||
fi
|
||||
|
||||
gopt=
|
||||
if [[ $1 = "-g" ]]; then gopt="--graph";
|
||||
fi
|
||||
|
||||
|
||||
git log --pretty=format:'%C(bold)%Cred%an (%Cgreen%cd):%Creset %s' \
|
||||
--date=format:'%d-%m-%y--%H:%M' ${gopt}
|
||||
|
||||
|
||||
}
|
||||
|
||||
# $usrto is the remote name. $usrfrom is a branch name.
|
||||
disseminate () {
|
||||
if ! [[ -d "${PWD}/.git" ]]; then
|
||||
echo "You must be in a git repo root to use this command!"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: disseminate <remote-user-name>"
|
||||
echo "Please supply the name of the user you wish to send your message to!"
|
||||
return
|
||||
fi
|
||||
|
||||
usrfrom="$(git branch --show-current)"
|
||||
usrto="$1"
|
||||
|
||||
|
||||
# Ensure remote exists
|
||||
if ! git remote get-url "$usrto" > /dev/null 2>&1; then
|
||||
echo "No such remote. You must first add a remote for ${usrto}"
|
||||
echo "How to add: git remote add $usrto <Repo-Url>"
|
||||
return
|
||||
fi
|
||||
|
||||
if ! git push "${usrto}" "${usrfrom}"; then
|
||||
echo "Failed to push to ${usrto}. Check permissions or network issues."
|
||||
return
|
||||
fi
|
||||
|
||||
}
|
||||
################################################################################
|
||||
# Don't use described commands. Not sure if safe.
|
||||
fetch-peers() {
|
||||
echo "Example to fetch all branches from a remote 'bob':"
|
||||
echo "git fetch bob"
|
||||
}
|
||||
|
||||
pull-remote() {
|
||||
echo "Example to pull changes from a specific branch on 'bob' remote:"
|
||||
echo "git pull bob <branch-name>"
|
||||
}
|
||||
|
||||
info() {
|
||||
echo "================================================="
|
||||
echo "Adding a remote:"
|
||||
echo "================================================="
|
||||
echo "git remote add <remote-name> <url-of-remote>"
|
||||
echo "Note that <remote-name> can be chosen arbitrarily"
|
||||
echo
|
||||
echo "================================================="
|
||||
echo "PUSHing to remote branch:"
|
||||
echo "================================================="
|
||||
echo "git push <remote-name> <the-local-branch-to-push>"
|
||||
echo "Example: Push branch 'Carol' to remote 'bob'"
|
||||
echo "git push bob Carol"
|
||||
echo "After this the remote 'bob' will have everything from your branch 'Carol' also on a branch called 'Carol'"
|
||||
echo
|
||||
echo "WARNING: Do not use 'git push Bob Carol' if you added remote 'bob' like this: 'git remote add bob ../Bob'"
|
||||
echo "This only means that you are adding a remote in .git/refs/remote, not a branch on your part."
|
||||
echo
|
||||
echo "================================================="
|
||||
echo "Some others:"
|
||||
echo "================================================="
|
||||
fetch-peers
|
||||
echo
|
||||
echo
|
||||
pull-remote
|
||||
echo
|
||||
echo "END INFO"
|
||||
}
|
||||
|
||||
|
||||
|
||||
echo "To use the functions, source this file from the command line:"
|
||||
echo "'source path/to/chatroom' or just 'source chatroom' if it is in the same directory."
|
||||
echo "After this the functions are available for the duration of your bash session as if they where built-in commands!"
|
||||
echo "That means to call the initialize function just type 'initialize' NOT './initialize'"
|
||||
echo "You will see this message again when you source the file."
|
||||
################################################################################
|
||||
# Useful for debugging
|
||||
################################################################################
|
||||
alias glog="git log --oneline --graph"
|
||||
alias gloga="git log --oneline --graph --all"
|
||||
9
bash/scripts/scripts/db23-arrange.sh
Executable file
9
bash/scripts/scripts/db23-arrange.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#! /usr/bin/bash
|
||||
filename=$1
|
||||
arrangedFolder=${PWD}/arranged
|
||||
newFilename=${filename:0:3}db23-arranged.pdf
|
||||
echo "Arranging $filename"
|
||||
/usr/bin/pdfjam --nup 2x2 --landscape --outfile $newFilename $filename
|
||||
echo "Moving $new-filename to $arranged-folder"
|
||||
mv $newFilename $arrangedFolder
|
||||
echo "Done"
|
||||
2
bash/scripts/scripts/mergeindir
Executable file
2
bash/scripts/scripts/mergeindir
Executable file
@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
qpdf --empty --pages $(ls -l | grep -v '^d' | sort) -- "$1.pdf"
|
||||
37
bash/scripts/scripts/mergepdfs
Executable file
37
bash/scripts/scripts/mergepdfs
Executable file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Check if qpdf is installed
|
||||
if ! command -v qpdf &> /dev/null; then
|
||||
echo "Error: qpdf could not be found. Please install qpdf."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Target PDF filename
|
||||
output_pdf="$1.pdf"
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "Usage: $0 <output-file-base-name>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Prepare an array to hold the PDF files
|
||||
pdf_files=()
|
||||
shopt -s nullglob
|
||||
for file in *.pdf; do
|
||||
pdf_files+=("$file")
|
||||
done
|
||||
|
||||
# Check if we found any PDF files
|
||||
if [[ ${#pdf_files[@]} -eq 0 ]]; then
|
||||
echo "No PDF files found in the current directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Sort files just in case
|
||||
IFS=$'\n' pdf_files=($(sort <<<"${pdf_files[*]}"))
|
||||
unset IFS
|
||||
|
||||
# Run qpdf to combine PDF files
|
||||
qpdf --empty --pages "${pdf_files[@]}" -- "$output_pdf"
|
||||
|
||||
echo "PDF files combined into $output_pdf"
|
||||
|
||||
10
bash/scripts/scripts/pr23-arrange.sh
Executable file
10
bash/scripts/scripts/pr23-arrange.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
filename=$1
|
||||
arrangedFolder=${PWD}/arranged
|
||||
newFilename=${filename}-pr23-arranged.pdf
|
||||
echo "Arranging $filename"
|
||||
/usr/bin/pdfjam --nup 2x1 --landscape --outfile $newFilename $filename
|
||||
echo "Moving $newFilename to $arrangedFolder"
|
||||
mv $newFilename $arrangedFolder
|
||||
echo "Done"
|
||||
@ -1,3 +1,10 @@
|
||||
[user]
|
||||
email = 74497638+sebaschi@users.noreply.github.com
|
||||
name = Sebastian Lenzlinger
|
||||
[http]
|
||||
sslVerify = false
|
||||
[filter "lfs"]
|
||||
clean = git-lfs clean -- %f
|
||||
smudge = git-lfs smudge -- %f
|
||||
process = git-lfs filter-process
|
||||
required = true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user