bin: clean up & update some scripts

This commit is contained in:
xerus2000 2021-03-23 21:55:02 +01:00
parent 3f341e97a8
commit 130b26c978
5 changed files with 17 additions and 40 deletions

View File

@ -31,6 +31,7 @@ rr() { mv "$@" /tmp }
alias j='jrnl' alias j='jrnl'
jn() { jrnl -to today "$@" | bat --style=plain --pager="less +G" } jn() { jrnl -to today "$@" | bat --style=plain --pager="less +G" }
alias jnc='jn -contains'
# like "which", but shows contents if it resolves to a file # like "which", but shows contents if it resolves to a file
wh() { wh() {
@ -378,44 +379,6 @@ function zipdiff() {
diff -W200 -y <(unzip -vql $1 | sort -k8) <(unzip -vql $2 | sort -k8) #--suppress-common-lines diff -W200 -y <(unzip -vql $1 | sort -k8) <(unzip -vql $2 | sort -k8) #--suppress-common-lines
} }
# PROJECTS
pdiff() {
diff -r $1 $2 -x .git -x .idea -x .gradle
}
genssh() {
mkdir -p ~/.ssh
test -f ~/.ssh/id_rsa.pub || ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa -q -N ""
cat ~/.ssh/id_rsa.pub
if test "$OSTYPE" = "cygwin"
then cat ~/.ssh/id_rsa.pub>/dev/clipboard
else xclip -sel clip 2>/dev/null < ~/.ssh/id_rsa.pub
fi && echo "SSH Public key copied to clipboard" || return 0
}
createproject() {
mkcd $1
echo 'plugins {
kotlin("jvm") version "1.3.41"
application
id("com.github.johnrengelman.shadow") version "5.1.0"
id("com.github.ben-manes.versions") version "0.21.0"
}
sourceSets {
main {
java.srcDir("src/main")
resources.srcDir("src/resources")
}
test {
java.srcDir("src/test")
}
}' > build.gradle.kts
}
# SWAP # SWAP
alias memstat='free -h | awk '"'"'NR==2 {printf "Free memory:\t %s/%s\t(%d%)\n",$7,$2,$7*100/$2} NR==3 {if($2 != "0B") printf "Used swap:\t%s/%s\t(%d%)\n",$3,$2,$2*100/$3}'"'" alias memstat='free -h | awk '"'"'NR==2 {printf "Free memory:\t %s/%s\t(%d%)\n",$7,$2,$7*100/$2} NR==3 {if($2 != "0B") printf "Used swap:\t%s/%s\t(%d%)\n",$3,$2,$2*100/$3}'"'"

View File

@ -20,7 +20,7 @@ git() {
yadm "$@" yadm "$@"
return return
;; ;;
$XDG_CONFIG_HOME*) $XDG_CONFIG_HOME*|$HOME/.local*)
if ! command git rev-parse --show-toplevel &>/dev/null; then if ! command git rev-parse --show-toplevel &>/dev/null; then
export LAST_YADM="$PWD" export LAST_YADM="$PWD"
yadm "$@" yadm "$@"

11
.local/bin/scripts/genssh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
keys="$HOME/.ssh/keys"
name="${1:-id_rsa}"
mkdir -p "$keys"
test -f "$keys/$name.pub" || ssh-keygen -t rsa -b 4096 -f "$keys/$name" -q -N ""
cat "$keys/$name.pub"
if test "$OSTYPE" = "cygwin"
then cat "$keys/$name.pub">/dev/clipboard
else xclip -sel clip 2>/dev/null <"$keys/$name.pub"
fi && echo "SSH Public key copied to clipboard" || return 0

2
.local/bin/scripts/pdiff Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
diff -r $1 $2 -x .git -x .idea -x .gradle -x build -x cmake_build -x dist_newstyle

View File

@ -8,7 +8,8 @@ esac
echo "Keyboard layout update to $id($ACTION) at $(date)" >>/tmp/scripts.log echo "Keyboard layout update to $id($ACTION) at $(date)" >>/tmp/scripts.log
export XAUTHORITY="/run/user/1000/Xauthority" DISPLAY=:0 export XAUTHORITY="/run/user/1000/Xauthority" DISPLAY=:0
# setxkbmap "$id" #nodeadkeys # setxkbmap "$id" #nodeadkeys
test $(xkblayout-state print '%C') -gt 1 && $(dirname $(dirname $0))/xkblayout-state set $id xkbstate="$(dirname $(dirname $0))/xkblayout-state"
test "$(xkbstate print %C)" -gt 1 && xkbstate set $id
# Swap semicolon and colon - https://unix.stackexchange.com/questions/615799/swap-semicolon-colon-to-p-unexpected-cause-semicolon-colon-affected-by-cpas-lock # Swap semicolon and colon - https://unix.stackexchange.com/questions/615799/swap-semicolon-colon-to-p-unexpected-cause-semicolon-colon-affected-by-cpas-lock
# test "$id" = "eu" && xmodmap -e 'keysym semicolon = colon semicolon colon semicolon' # test "$id" = "eu" && xmodmap -e 'keysym semicolon = colon semicolon colon semicolon'
test "$id" = "1" && xmodmap -e 'keysym semicolon = colon semicolon colon semicolon' || setxkbmap de nodeadkeys test "$id" = "1" && xmodmap -e 'keysym semicolon = colon semicolon colon semicolon' || setxkbmap de nodeadkeys