summaryrefslogtreecommitdiff
path: root/config/essentials/zsh/functions.zsh
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-02-15 16:31:56 +0100
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-02-15 16:47:43 +0100
commit3b2a78935fd6550521f719a10e5b0fceb1ddb350 (patch)
tree7c50801d6bb5b7abba3df6352ed43df454a4dbcb /config/essentials/zsh/functions.zsh
Not really but, First commit!
Diffstat (limited to 'config/essentials/zsh/functions.zsh')
-rw-r--r--config/essentials/zsh/functions.zsh79
1 files changed, 79 insertions, 0 deletions
diff --git a/config/essentials/zsh/functions.zsh b/config/essentials/zsh/functions.zsh
new file mode 100644
index 0000000..a73ea15
--- /dev/null
+++ b/config/essentials/zsh/functions.zsh
@@ -0,0 +1,79 @@
+#!/bin/zsh
+
+vmp() {
+ col -b | \
+ vim -MR \
+ -c 'set ft=man nolist nonu nornu'
+}
+vimh() { vim -c "help $1" -c 'call feedkeys("\<c-w>o")' }
+
+nnn() { test -z "$NNNLVL" && /usr/bin/nnn "$@" || exit }
+ranger() { test -z "$RANGER_LEVEL" && /usr/bin/ranger "$@" || exit }
+
+# googoo
+o ()
+{
+ f="$(fzffile $1)"
+ test "$#" -gt 0 && shift
+ test -n "$f" && $EDITOR $@ "$f"
+}
+go ()
+{
+ d="$(fzfdir $1)"
+ test -d "$d" && cd "$d"
+}
+ogo ()
+{
+ d="$(fzfdirfile $1)"
+ test -d "$d" && cd "$d"
+}
+
+ipc ()
+{
+ if [[ "$(ip link show eno1 | awk -F, 'NR=1 {print $3}')" == "UP" ]]
+ then
+ doas ip link set eno1 down
+ else
+ doas ip link set eno1 up
+ fi
+}
+
+calc () { echo "$@" | bc -l }
+
+unique () {
+ f="/tmp/$(uuidgen)"
+ awk '!x[$0]++' "$1" > "$f"
+ mv "$f" "$1"
+}
+
+clip () { echo -n "$@" | xclip -selection clipboard -rmlastnl }
+
+fzh () {
+ choice="$(tac $HOME/.config/zsh/histfile | fzf)"
+ test -z "${choice}" && return
+ echo "${choice}" >> "${HOME}/.config/zsh/histfile"
+ eval "${choice}"
+}
+
+unzipp () {
+ file=$1
+ shift
+ unzip $file $@ || exit 1
+ rm $file
+}
+
+# fix long waiting time
+__git_files () {
+ _wanted files expl 'local files' _files
+}
+
+# allows changing to parent dir of file
+function cd () {
+ if (( ${#argv} == 1 )) && [[ -f ${1} ]]; then
+ [[ ! -e ${1:h} ]] && return 1
+ print "Correcting ${1} to ${1:h}"
+ builtin cd ${1:h}
+ else
+ builtin cd "$@"
+ fi
+}