Skip to content

Commit

Permalink
refactor fhelp function to combine git docker functions and piep them…
Browse files Browse the repository at this point in the history
… to fzf
  • Loading branch information
victory-sokolov committed Dec 26, 2024
1 parent 428c2f4 commit d4e3378
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions zsh/.functions
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
#!/bin/zsh
# shellcheck shell=bash

fhelp() # List all custom functions
{
rg -N '^[a-zA-Z]' \
"$DOTFILES"/zsh/.functions \
"$DOTFILES"/git/.git-functions \
"$DOTFILES"/zsh/.dockerfunc \
| sed -E 's/\(\)\s*#\s*/ /' \
| sed 's/^[^:]*://' \
| sort \
| fzf --preview="echo {} | awk -F' ' '{\$1=\"\"; print substr(\$0,2)}'" \
--with-nth=1 \
--delimiter=' '
}


_has() # Check whether executable exists
{
command -v "$1" >/dev/null 2>&1
}

_fzf-down()
{
fzf --height 50% "$@"
}

latest() # Show latest created file
{
ls -lt -d "$1"/*/ | head -n1 | awk '{print $NF}'
Expand Down Expand Up @@ -131,17 +151,6 @@ targz() # Targz a file
echo "${tmpFile}.gz ($((zippedSize / 1000)) kB) created successfully.";
}

# Normalize `open` across Linux, macOS, and Windows.
# This is needed to make the `o` function (see below) cross-platform.
if [ ! "$(uname -s)" = 'Darwin' ]; then
if grep -q Microsoft /proc/version; then
# Ubuntu on Windows using the Linux subsystem
alias open='explorer.exe';
else
alias open='xdg-open';
fi
fi

cview() # Read csv file
{
csvtool readable "$1" | view -
Expand Down Expand Up @@ -195,10 +204,6 @@ gifify() # Video to GIF
fi
}

fzf-down() {
fzf --height 50% "$@"
}

fcd() # FZF with cd command
{
local DIR=$(
Expand Down Expand Up @@ -525,8 +530,8 @@ node-flush() # Reinstall node deps
fi
}

# Get Node package manager
get_node_package_manager() {
get_node_package_manager() # Get Node package manager
{
if [[ -f bun.lockb ]]; then
echo "bun"
elif [[ -f pnpm-lock.yaml ]]; then
Expand Down

0 comments on commit d4e3378

Please sign in to comment.