mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-30 02:44:42 +01:00
Merge branch 'ohmyzsh:master' into conda
This commit is contained in:
commit
cb471f56ef
13 changed files with 102 additions and 46 deletions
|
|
@ -1,10 +1,3 @@
|
|||
# copydir plugin
|
||||
|
||||
Copies the path of your current folder to the system clipboard.
|
||||
|
||||
To use, add `copydir` to your plugins array:
|
||||
```
|
||||
plugins=(... copydir)
|
||||
```
|
||||
|
||||
Then use the command `copydir` to copy the $PWD.
|
||||
This plugin is deprecated. Use the [`copypath` plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/copypath) instead.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
# Copies the pathname of the current directory to the system or X Windows clipboard
|
||||
echo ${(%):-'%F{yellow}The `%Bcopydir%b` plugin is deprecated. Use the `%Bcopypath%b` plugin instead.%f'}
|
||||
source "$ZSH/plugins/copypath/copypath.plugin.zsh"
|
||||
|
||||
# TODO: 2022-02-22: Remove deprecated copydir function.
|
||||
function copydir {
|
||||
emulate -L zsh
|
||||
print -n $PWD | clipcopy
|
||||
copypath
|
||||
}
|
||||
|
|
|
|||
15
plugins/copypath/README.md
Normal file
15
plugins/copypath/README.md
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# copypath plugin
|
||||
|
||||
Copies the path of given directory or file to the system clipboard.
|
||||
|
||||
To use it, add `copypath` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... copypath)
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
- `copypath`: copies the absolute path of the current directory.
|
||||
|
||||
- `copypath <file_or_directory>`: copies the absolute path of the given file.
|
||||
15
plugins/copypath/copypath.plugin.zsh
Normal file
15
plugins/copypath/copypath.plugin.zsh
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Copies the path of given directory or file to the system or X Windows clipboard.
|
||||
# Copy current directory if no parameter.
|
||||
function copypath {
|
||||
# If no argument passed, use current directory
|
||||
local file="${1:-.}"
|
||||
|
||||
# If argument is not an absolute path, prepend $PWD
|
||||
[[ $file = /* ]] || file="$PWD/$file"
|
||||
|
||||
# Copy the absolute path without resolving symlinks
|
||||
# If clipcopy fails, exit the function with an error
|
||||
print -n "${file:a}" | clipcopy || return 1
|
||||
|
||||
echo ${(%):-"%B${file:a}%b copied to clipboard."}
|
||||
}
|
||||
|
|
@ -52,7 +52,10 @@ source_env() {
|
|||
fi
|
||||
|
||||
# test .env syntax
|
||||
zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2
|
||||
zsh -fn $ZSH_DOTENV_FILE || {
|
||||
echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
setopt localoptions allexport
|
||||
source $ZSH_DOTENV_FILE
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ command mkdir -p "$ZSH_CACHE_DIR/completions"
|
|||
# If the completion file does not exist, generate it and then source it
|
||||
# Otherwise, source it and regenerate in the background
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_helm" ]]; then
|
||||
helm completion zsh >| "$ZSH_CACHE_DIR/completions/_helm"
|
||||
helm completion zsh | tee "$ZSH_CACHE_DIR/completions/_helm" >/dev/null
|
||||
source "$ZSH_CACHE_DIR/completions/_helm"
|
||||
else
|
||||
source "$ZSH_CACHE_DIR/completions/_helm"
|
||||
helm completion zsh >| "$ZSH_CACHE_DIR/completions/_helm" &|
|
||||
helm completion zsh | tee "$ZSH_CACHE_DIR/completions/_helm" >/dev/null &|
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ if (( $+commands[kubectl] )); then
|
|||
# If the completion file does not exist, generate it and then source it
|
||||
# Otherwise, source it and regenerate in the background
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_kubectl" ]]; then
|
||||
kubectl completion zsh >| "$ZSH_CACHE_DIR/completions/_kubectl"
|
||||
kubectl completion zsh | tee "$ZSH_CACHE_DIR/completions/_kubectl" >/dev/null
|
||||
source "$ZSH_CACHE_DIR/completions/_kubectl"
|
||||
else
|
||||
source "$ZSH_CACHE_DIR/completions/_kubectl"
|
||||
kubectl completion zsh >| "$ZSH_CACHE_DIR/completions/_kubectl" &|
|
||||
kubectl completion zsh | tee "$ZSH_CACHE_DIR/completions/_kubectl" >/dev/null &|
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue