diff options
author | A Farzat <a@farzat.xyz> | 2024-02-28 15:51:30 +0900 |
---|---|---|
committer | A Farzat <a@farzat.xyz> | 2024-10-14 15:51:30 +0900 |
commit | 42357c10435c0358c38fe1435b0c8ec0a6b99d59 (patch) | |
tree | e21933d6f5564d3e61c81e34340fa9c0dd5ebc9d /halfway/functions.zsh | |
parent | ca38e20ca116d89984275014dca8cc2bc9d7a1e2 (diff) | |
download | zsh-42357c10435c0358c38fe1435b0c8ec0a6b99d59.tar.gz zsh-42357c10435c0358c38fe1435b0c8ec0a6b99d59.zip |
Add functions
Diffstat (limited to 'halfway/functions.zsh')
-rw-r--r-- | halfway/functions.zsh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/halfway/functions.zsh b/halfway/functions.zsh new file mode 100644 index 0000000..54c813b --- /dev/null +++ b/halfway/functions.zsh @@ -0,0 +1,53 @@ +# Creates the given directories and then moves to the first one. +mkcd() { + mkdir -p "$@"; + cd "$1"; +} + +# Create python directories with __init__.py. +mkdirpython() { + mkdir -p "$@"; + local directory + for directory in "$@"; + do touch "$directory/__init__.py"; + done; +} + +# Switch from the current directory to the equivalent directory on another drive. +sd() { + local wd="$(pwd)"; + wd="${wd/"$1"/"$2"}"; + printf %s\\n "$wd"; + cd "$wd"; +} + +# Copy the current directory to the clipboard. +pcopy() { + printf %s "$(pwd)" | cclip + pwd +} + +vinfo() { + INFOPATH="$XDG_DATA_HOME/info:$INFOPATH" $EDITOR -R -M -c "Info $@" +only +} + +vn3() { + if [ "$#" -gt 0 ]; then + local direc="$(printf %q "$1")" + shift + $EDITOR -c "NnnExplorer $direc" "$@" + else + $EDITOR -c NnnExplorer + fi +} + +# https://github.com/ohmyzsh/ohmyzsh/blob/8487a55/lib/cli.zsh#L625 +src () { + # Delete current completion cache + command rm -f $_comp_dumpfile $ZSH_COMPDUMP + + # Old zsh versions don't have ZSH_ARGZERO + local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}" + # Check whether to run a login shell + [[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh" +} |