summaryrefslogtreecommitdiff
path: root/config/essentials/zsh
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-12-12 00:13:46 +0100
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-12-12 00:13:59 +0100
commit9dbc981d781dac4ddd96e50f598fb0a267e8a299 (patch)
tree525a9c28b638234084dfb7a0a84a95b8bc37253b /config/essentials/zsh
parent445de8fd7e76c986f796774179d3adb6721f2acf (diff)
renamed functions.zsh
Diffstat (limited to 'config/essentials/zsh')
-rw-r--r--config/essentials/zsh/.zshrc2
-rw-r--r--config/essentials/zsh/functions.sh (renamed from config/essentials/zsh/functions.zsh)52
2 files changed, 27 insertions, 27 deletions
diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc
index c590d54..7b1f7a0 100644
--- a/config/essentials/zsh/.zshrc
+++ b/config/essentials/zsh/.zshrc
@@ -67,7 +67,7 @@ zle -N add-surround surround
zle -N change-surround surround
# Source files
-. $ZDOTDIR/functions.zsh
+. $ZDOTDIR/functions.sh
. $ZDOTDIR/aliases.sh
for file in /{etc,usr/lib}/os-release
diff --git a/config/essentials/zsh/functions.zsh b/config/essentials/zsh/functions.sh
index 98cca08..b285e05 100644
--- a/config/essentials/zsh/functions.zsh
+++ b/config/essentials/zsh/functions.sh
@@ -1,4 +1,4 @@
-#!/bin/zsh
+#!/bin/sh
log() { >&2 printf '%s' "$@"; }
logn() { >&2 printf '%s\n' "$@"; }
@@ -9,8 +9,8 @@ vmp() {
-c 'set ft=man nolist nonu nornu'
}
nvf() {
- local cache="$HOME/.cache/nvf"
- local match="$(grep -m1 "$1$" "$cache" 2> /dev/null)"
+ cache="$HOME/.cache/nvf"
+ match="$(grep -m1 "$1$" "$cache" 2> /dev/null)"
if test ! -f "$match"
then
logn "resetting cache..."
@@ -26,8 +26,8 @@ nvf() {
fi
}
-nnn() { test -z "$NNNLVL" && /usr/bin/nnn "$@" || exit }
-ranger() { test -z "$RANGER_LEVEL" && /usr/bin/ranger "$@" || exit }
+nnn() { test -z "$NNNLVL" && /usr/bin/nnn "$@" || exit; }
+ranger() { test -z "$RANGER_LEVEL" && /usr/bin/ranger "$@" || exit; }
# googoo aliases
_googoo_fzf_opt()
@@ -62,7 +62,7 @@ vimh() { vi -c "help $1" -c 'call feedkeys("\<c-w>o")'; }
dgo() { cd "$(goo d ~ | fzf --filter "$@" | head -n 1)"; }
open() { $EDITOR "$(goo f ~ | fzf --filter "$@" | head -n 1)"; }
pkbs() { doas pacman -Sy "$(pkgfile -b "$1" | tee /dev/stderr)"; }
-oclip() { printf "\033]52;c;$(echo -n "$@" | base64)\a"; }
+oclip() { printf "\033]52;c;$(printf '%s' "$@" | base64)\a"; }
sms() { ssh -t phone sendmsg "$1" "'$2'"; }
trcp() { scp "$1" db:/media/basilisk/downloads/transmission/torrents/; }
rln() { ln -s "$(readlink -f "$1")" "$2"; }
@@ -70,7 +70,7 @@ getgit() { git clone git@db:"$1"; }
ipc()
{
- if [[ "$(ip link show eno1 | awk -F, 'NR=1 {print $3}')" == "UP" ]]
+ if [ "$(ip link show eno1 | awk -F, 'NR=1 {print $3}')" = "UP" ]
then
doas ip link set eno1 down
else
@@ -85,7 +85,6 @@ psgrep()
}
unique() {
- local f
f="$(mktemp)"
awk '!x[$0]++' "$1" > "$f"
mv "$f" "$1"
@@ -152,16 +151,16 @@ ginit()
# Returns current branch
git_current_branch()
{
- command git rev-parse --git-dir &>/dev/null || return
+ command git rev-parse --git-dir > /dev/null 2>&1 || return
git branch --show-current
}
# Check if main exists and use instead of master
git_main_branch()
{
- command git rev-parse --git-dir &>/dev/null || return
- local ref
- for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default}; do
+ command git rev-parse --git-dir > /dev/null 2>&1 || return
+ for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default}
+ do
if command git show-ref -q --verify $ref; then
echo ${ref:t}
return
@@ -172,10 +171,11 @@ git_main_branch()
# Check for develop and similarly named branches
function git_develop_branch() {
- command git rev-parse --git-dir &>/dev/null || return
- local branch
- for branch in dev devel development; do
- if command git show-ref -q --verify refs/heads/$branch; then
+ command git rev-parse --git-dir > /dev/null 2>&1 || return
+ for branch in dev devel development
+ do
+ if command git show-ref -q --verify refs/heads/$branch
+ then
echo $branch
return
fi
@@ -186,11 +186,14 @@ function git_develop_branch() {
# gpg backup
gpg_backup()
{
- gpg --export-secret-keys --armor > private.asc
- gpg --export --armor > public.asc
- gpg --export-ownertrust --armor > trust.asc
- tar czf gpg_backup.tar.gz {public,private,trust}.asc
- shred -uz {public,private,trust}.asc
+ # $1: option
+ # $2: output file (without .asc)
+ gpg_command() {gpg "$1" --armor > "$2".asc ; }
+ gpg_command --export-secret-keys "private"
+ gpg_command --export "public"
+ gpg_command --export-ownertrust "trust"
+ tar -czvf gpg_backup.tar.gz public.asc private.asc trust.asc
+ shred -uz public.asc private.asc trust.asc
}
gpg_import()
@@ -200,7 +203,7 @@ gpg_import()
gpg --import public.asc
gpg --import-ownertrust trust.asc
gpg --import private.asc
- shred -uz {public,private,trust}.asc
+ shred -uz public.asc private.asc trust.asc
}
ngenable()
@@ -242,7 +245,6 @@ pacsize()
mime-default ()
{
- local mime
[ "${mime:=$1}" ] ||
mime="$(find /usr/share/applications/ -iname '*.desktop' -printf '%f\n' |
sed 's/\.desktop$//' |
@@ -259,7 +261,7 @@ mime-default ()
addedkeys() {
find ~/.ssh -iname "*.pub" | while read key
do
- local fingerprint="$(ssh-keygen -lf "$key" 2>/dev/null)"
+ fingerprint="$(ssh-keygen -lf "$key" 2>/dev/null)"
if ssh-add -l | grep -q "$fingerprint"
then
echo "$key"
@@ -277,8 +279,6 @@ fpass() {
muttmail()
{
- local config
- local mail
config="$HOME/.config/mutt"
mail="$(find "$config"/configs -type f -printf '%f\n' | fzf)"
[ "$mail" ] || return 1