new plugins

This commit is contained in:
2020-03-12 10:39:14 -04:00
parent ff00e65884
commit 6f4200dfd3
3 changed files with 69 additions and 0 deletions

59
bd/bd.plugin.zsh Executable file
View File

@@ -0,0 +1,59 @@
#! /bin/bash
alias bd="bdfn -si"
usage_error () {
cat << EOF
------------------------------------------------------------------
Name: bd
Version: 1.02
------------------------------------------------------------------
Description: Go back to a specified directory up in the hierarchy.
------------------------------------------------------------------
How to use:
Please refer https://github.com/vigneshwaranr/bd
EOF
}
newpwd() {
oldpwd=$1
case "$2" in
-s)
pattern=$3
NEWPWD=$(echo $oldpwd | sed 's|\(.*/'$pattern'[^/]*/\).*|\1|')
;;
-si)
pattern=$3
NEWPWD=$(echo $oldpwd | perl -pe 's|(.*/'$pattern'[^/]*/).*|$1|i')
;;
*)
pattern=$2
NEWPWD=$(echo $oldpwd | sed 's|\(.*/'$pattern'/\).*|\1|')
esac
}
bdfn() {
if [ $# -eq 0 ]
then
usage_error
elif [ "${@: -1}" = -v ]
then
usage_error
else
oldpwd=$(pwd)
newpwd "$oldpwd" "$@"
if [ "$NEWPWD" = "$oldpwd" ]
then
echo "No such occurrence."
else
echo $NEWPWD
cd "$NEWPWD"
fi
unset NEWPWD
fi
}

7
code/code.plugin.zsh Executable file
View File

@@ -0,0 +1,7 @@
alias vscode="code"
alias vs-code="code"
alias cdiff="code -d"
alias cadd="code -a"
alias cnew="code -n"
alias code-install="code --install-extension"
alias code-uninstall="code --uninstall-extension"

3
copy/copy.plugin.zsh Executable file
View File

@@ -0,0 +1,3 @@
xcopy() { $1 | xclip -selection clipboard; }
xcopyf() { cat $1 | xclip -selection clipboard; }
xpaste() { xclip -selection clipboard -o; }