Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
8d08f163
Unverified
Commit
8d08f163
authored
Aug 27, 2020
by
Pavol Juhas
Committed by
GitHub
Aug 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scd: update to 1.4.0 (#9066)
parent
cfb86cd0
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
355 additions
and
118 deletions
+355
-118
README.md
plugins/scd/README.md
+45
-9
_scd
plugins/scd/_scd
+60
-0
scd
plugins/scd/scd
+243
-100
scd.plugin.zsh
plugins/scd/scd.plugin.zsh
+7
-9
No files found.
plugins/scd/README.md
View file @
8d08f163
...
@@ -14,8 +14,9 @@ directory aliases, which appear as named directories in zsh session.
...
@@ -14,8 +14,9 @@ directory aliases, which appear as named directories in zsh session.
## INSTALLATION NOTES
## INSTALLATION NOTES
Besides oh-my-zsh,
`scd`
can be used with
*bash*
,
*dash*
or
*tcsh*
Besides oh-my-zsh,
`scd`
can be used with
*bash*
,
*dash*
or
*tcsh*
shells and is also available as
[
Vim
](
https://www.vim.org/
)
plugin and
shells and is also available as Vim plugin
[
IPython
](
https://ipython.org/
)
extension. For installation details, see
[
scd.vim
](
https://github.com/pavoljuhas/scd.vim
)
and
[
IPython
](
https://ipython.org
)
extension. For installation details, see
https://github.com/pavoljuhas/smart-change-directory.
https://github.com/pavoljuhas/smart-change-directory.
## SYNOPSIS
## SYNOPSIS
...
@@ -24,11 +25,31 @@ https://github.com/pavoljuhas/smart-change-directory.
...
@@ -24,11 +25,31 @@ https://github.com/pavoljuhas/smart-change-directory.
scd
[
options]
[
pattern1 pattern2 ...]
scd
[
options]
[
pattern1 pattern2 ...]
```
```
## PATTERNS
Patterns may use all zsh
[
glob operators
](
http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Operators
)
available with
*extendedglob*
option. Specified patterns must match
the absolute path and at least one of them must match in the tail.
Several special patterns are also recognized as follows:
<dl><dt>
^PAT
</dt><dd>
PAT must match at the beginning of the path, for example, "^/home"
</dd><dt>
PAT$
</dt><dd>
require PAT to match the end of the path, "man$"
</dd><dt>
./
</dt><dd>
match only subdirectories of the current directory
</dd><dt>
:PAT
</dt><dd>
require PAT to match over the tail component, ":doc", ":re/doc"
</dd>
</dl>
## OPTIONS
## OPTIONS
<dl><dt>
<dl><dt>
-a, --add
</dt><dd>
-a, --add
</dt><dd>
add specified directories to the directory index.
</dd><dt>
add
current or
specified directories to the directory index.
</dd><dt>
--unindex
</dt><dd>
--unindex
</dt><dd>
remove current or specified directories from the index.
</dd><dt>
remove current or specified directories from the index.
</dd><dt>
...
@@ -42,11 +63,16 @@ scd [options] [pattern1 pattern2 ...]
...
@@ -42,11 +63,16 @@ scd [options] [pattern1 pattern2 ...]
--unalias
</dt><dd>
--unalias
</dt><dd>
remove ALIAS definition for the current or specified directory from
remove ALIAS definition for the current or specified directory from
<em>
~/.scdalias.zsh
</em>
.
</dd><dt>
<em>
~/.scdalias.zsh
</em>
. Use "OLD" to purge aliases to non-existent
directories.
</dd><dt>
-A, --all
</dt><dd>
-A, --all
</dt><dd>
include all matching directories. Disregard matching by directory
display all directories even those excluded by patterns in
alias and filtering of less likely paths.
</dd><dt>
<em>
~/.scdignore
</em>
. Disregard the unique matching for a
directory alias and filtering of less likely paths.
</dd><dt>
-p, --push
</dt><dd>
use "pushd" to change to the target directory.
</dd><dt>
--list
</dt><dd>
--list
</dt><dd>
show matching directories and exit.
</dd><dt>
show matching directories and exit.
</dd><dt>
...
@@ -58,6 +84,7 @@ scd [options] [pattern1 pattern2 ...]
...
@@ -58,6 +84,7 @@ scd [options] [pattern1 pattern2 ...]
display this options summary and exit.
</dd>
display this options summary and exit.
</dd>
</dl>
</dl>
## Examples
## Examples
```
sh
```
sh
...
@@ -83,17 +110,26 @@ scd --alias=xray
...
@@ -83,17 +110,26 @@ scd --alias=xray
scd xray
scd xray
```
```
# FILES
#
#
FILES
<dl><dt>
<dl><dt>
~/.scdhistory
</dt><dd>
~/.scdhistory
</dt><dd>
time-stamped index of visited directories.
</dd><dt>
time-stamped index of visited directories.
</dd><dt>
~/.scdalias.zsh
</dt><dd>
~/.scdalias.zsh
</dt><dd>
scd-generated definitions of directory aliases.
</dd>
scd-generated definitions of directory aliases.
</dd><dt>
~/.scdignore
</dt><dd>
<a
href=
"http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Operators"
>
glob patterns
</a>
for paths to be ignored in the scd search, for example,
<code>
/mnt/backup/
*
</code>
. The patterns are specified one per line
and are matched assuming the
<em>
extendedglob
</em>
zsh option. Lines
starting with "#" are skipped as comments. The .scdignore patterns
are not applied in the
<em>
--all
</em>
mode.
</dd>
</dl>
</dl>
# ENVIRONMENT
## ENVIRONMENT
<dl><dt>
<dl><dt>
SCD_HISTFILE
</dt><dd>
SCD_HISTFILE
</dt><dd>
...
...
plugins/scd/_scd
0 → 100644
View file @
8d08f163
#compdef scd
#description smart change directory
local curcontext="$curcontext" state line expl ret=1
typeset -A opt_args
local -a indexopts myargs
indexopts=( --add -a --unindex )
myargs=(
# common options
"(--help -h)"{--help,-h}"[print help and exit]"
# options for manipulating directory index
- index
"(--recursive -r)"{--recursive,-r}"[use recursive --add or --unindex]"
"($indexopts)"{--add,-a}"[add specified directories to the index]"
"($indexopts)--unindex[remove specified directories from the index]"
"*:directory:{ (( ${words[(I)-a|--add|--unindex]} )) && _path_files -/ }"
# define new directory alias
- alias
"--alias=[create alias for this or given directory]:directory-alias:()"
'1:directory:{ (( words[(I)--alias*] )) && _path_files -/ }'
# remove definition of directory alias
- unalias
"--unalias[remove definition of directory alias]"
"*::directory alias:->scd-alias-target"
# act on the directory change
- scd
"(--all -A)"{--all,-A}"[include less likely and ignored paths]"
"--list[print matching directories and exit]"
"(--verbose -v)"{--verbose,-v}"[show directory ranking and full paths]"
"(--push -p)"{--push,-p}"[change directory with 'pushd']"
"1::directory alias:->scd-alias-target"
"*:patterns:()"
)
_arguments -S -C $myargs && ret=0
if [[ "$state" == scd-alias-target && -s ~/.scdalias.zsh ]]; then
local -a scdaliases
scdaliases=( )
eval "$(setopt extendedglob
phome="(#b)(#s)${HOME}(/*)#(#e)"
builtin hash -dr
source ~/.scdalias.zsh &&
for k v in ${(kv)nameddirs}; do
scdaliases+=( $k:${v/${~phome}/"~"${match[1]}} )
done
complete_unalias=${+opt_args[unalias---unalias]}
if (( complete_unalias && ! ${+nameddirs[OLD]} )); then
scdaliases+=( 'OLD:all aliases to non-existent paths' )
fi
typeset -p scdaliases )"
_describe -t scdaliases scdalias scdaliases
fi
plugins/scd/scd
100644 → 100755
View file @
8d08f163
This diff is collapsed.
Click to expand it.
plugins/scd/scd.plugin.zsh
View file @
8d08f163
## The scd script should autoload as a shell function.
## The scd script should autoload as a shell function.
autoload scd
autoload
-Uz
scd
## If the scd function exists, define a change-directory-hook function
## If the scd function exists, define a change-directory-hook function
## to record visited directories in the scd index.
## to record visited directories in the scd index.
if
[[
${
+functions[scd]
}
==
1
]]
;
then
if
[[
${
+functions[scd]
}
==
1
]]
;
then
scd_chpwd_hook
()
{
scd
--add
$PWD
}
chpwd_scd
()
{
scd
--add
$PWD
}
autoload add-zsh-hook
autoload
-Uz
add-zsh-hook
add-zsh-hook chpwd
scd_chpwd_hook
add-zsh-hook chpwd
chpwd_scd
fi
fi
## Allow scd usage with unquoted wildcard characters such as "*" or "?".
alias
scd
=
'noglob scd'
## Load the directory aliases created by scd if any.
## Load the directory aliases created by scd if any.
if
[[
-s
~/.scdalias.zsh
]]
;
then
source
~/.scdalias.zsh
;
fi
if
[[
-s
~/.scdalias.zsh
]]
;
then
source
~/.scdalias.zsh
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment