1
Fork 0
dots/zsh/zsh-functions
2024-05-05 05:57:59 +05:00

42 lines
1,005 B
Bash

function cc() python -c "from math import *; print($*)"
function mkcd() mkdir -p -- $1 && cd -- $1
function save-ssh-key() {
mkdir -p "$HOME/.ssh"
chmod 700 "$HOME/.ssh"
mv "$1" "$HOME/.ssh/${1}_${2}"
if [ -e "$1.pub" ]; then
mv -n "$1.pub" "$HOME/.ssh/${1}_${2}.pub"
fi
}
function eik() {
kitten edit-in-kitty "$1"
}
function find-directory() {
FOLDER=$(fd -t d --hidden | fzf --height="~50%" --reverse)
if [ -n "$FOLDER" ]; then
BUFFER="cd $FOLDER; l"
zle .accept-line
else
zle reset-prompt
fi
}
zle -N find-directory
function forgejo_clone() {
local repo_name
repo_name=$(curl -X GET "https://git.hadeedahmad.xyz/api/v1/user/repos" \
-H "Authorization: token ${FORGEJO_API_KEY}" \
--silent | jq -r ".[].name" | fzf --height="~50%" --reverse)
if [ -n "$repo_name" ]; then
git clone "forgejo:hadeed/$repo_name"
fi
}
zle -N forgejo_clone
# vim: filetype=zsh