From: Sergey Matveev Date: Sun, 28 Nov 2021 08:25:32 +0000 (+0300) Subject: Make some functions autoloadable X-Git-Url: http://www.git.stargrave.org/?p=dotfiles.git;a=commitdiff_plain;h=657599511fa69afffa4e7167bb63e99abbdfcc23 Make some functions autoloadable --- diff --git a/zsh/.zsh/functions/cf b/zsh/.zsh/functions/cf new file mode 100644 index 0000000..f0ab759 --- /dev/null +++ b/zsh/.zsh/functions/cf @@ -0,0 +1,6 @@ +local dir=$(bfs -L ${1:-.} -mindepth 1 \ + -path "*/\.git" -prune -o \ + -path "*/\.redo" -prune -o \ + -type d -print 2>/dev/null | + fzf --height 40% --reverse --preview="tree -CN {}") +[[ -z $dir ]] || { print -s cd $dir ; cd $dir } diff --git a/zsh/.zsh/functions/f b/zsh/.zsh/functions/f new file mode 100644 index 0000000..5f02d04 --- /dev/null +++ b/zsh/.zsh/functions/f @@ -0,0 +1 @@ +bfs . -name "*$1*" -print diff --git a/zsh/.zsh/functions/g b/zsh/.zsh/functions/g new file mode 100644 index 0000000..7900244 --- /dev/null +++ b/zsh/.zsh/functions/g @@ -0,0 +1,11 @@ +local GREP_ARGS=( + --devices=skip + --colour=always + --with-filename + --line-number + --dereference-recursive + --binary-files=without-match + --exclude-dir=.git + --exclude-dir=.tags +) +grep $GREP_ARGS $@ | less diff --git a/zsh/.zsh/functions/ssht b/zsh/.zsh/functions/ssht new file mode 100644 index 0000000..bc50397 --- /dev/null +++ b/zsh/.zsh/functions/ssht @@ -0,0 +1,2 @@ +local t="-t 0" +TERM=xterm ssh -C -t $1 "tmux has-session $t && tmux attach-session $t || tmux new-session $t" diff --git a/zsh/.zsh/rc/010autoload.zsh b/zsh/.zsh/rc/010autoload.zsh new file mode 100644 index 0000000..e253807 --- /dev/null +++ b/zsh/.zsh/rc/010autoload.zsh @@ -0,0 +1 @@ +for f (~/.zsh/functions/*) autoload ${f:t} diff --git a/zsh/.zsh/rc/010cf.zsh b/zsh/.zsh/rc/010cf.zsh deleted file mode 100644 index 757409b..0000000 --- a/zsh/.zsh/rc/010cf.zsh +++ /dev/null @@ -1,8 +0,0 @@ -cf() { - local dir=$(bfs -L ${1:-.} -mindepth 1 \ - -path "*/\.git" -prune -o \ - -path "*/\.redo" -prune -o \ - -type d -print 2>/dev/null | - fzf --height 40% --reverse --preview="tree -CN {}") - [[ -z $dir ]] || { print -s cd $dir ; cd $dir } -} diff --git a/zsh/.zsh/rc/010f.zsh b/zsh/.zsh/rc/010f.zsh deleted file mode 100644 index 3626ac5..0000000 --- a/zsh/.zsh/rc/010f.zsh +++ /dev/null @@ -1,3 +0,0 @@ -f() { - bfs . -name "*$1*" -print -} diff --git a/zsh/.zsh/rc/010grep.zsh b/zsh/.zsh/rc/010grep.zsh index e2d979e..7a327ea 100644 --- a/zsh/.zsh/rc/010grep.zsh +++ b/zsh/.zsh/rc/010grep.zsh @@ -1,15 +1,2 @@ -GREP_ARGS=( - --devices=skip - --colour=always - --with-filename - --line-number - --dereference-recursive - --binary-files=without-match - --exclude-dir=.git - --exclude-dir=.tags -) -g() { - grep $GREP_ARGS $@ | less -} alias -g G="| grep --colour=always" alias gg="git grep " diff --git a/zsh/.zsh/rc/010ssh.zsh b/zsh/.zsh/rc/010ssh.zsh index 1d25770..81e8118 100644 --- a/zsh/.zsh/rc/010ssh.zsh +++ b/zsh/.zsh/rc/010ssh.zsh @@ -1,6 +1,2 @@ alias ssh="TERM=xterm ssh" alias sshnm="ssh -S none" -ssht() { - local t="-t 0" - TERM=xterm ssh -C -t $1 "tmux has-session $t && tmux attach-session $t || tmux new-session $t" -} diff --git a/zsh/.zsh/rc/010torn.zsh b/zsh/.zsh/rc/010torn.zsh deleted file mode 100644 index f122d5b..0000000 --- a/zsh/.zsh/rc/010torn.zsh +++ /dev/null @@ -1 +0,0 @@ -autoload torn