Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
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
104041a0
Unverified
Commit
104041a0
authored
Oct 19, 2023
by
Peat Bakke
Committed by
GitHub
Oct 19, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(tmux): add `tds` alias for directory sessions (#11987)
parent
0da41698
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
README.md
plugins/tmux/README.md
+1
-0
tmux.plugin.zsh
plugins/tmux/tmux.plugin.zsh
+13
-0
No files found.
plugins/tmux/README.md
View file @
104041a0
...
@@ -25,6 +25,7 @@ The plugin also supports the following:
...
@@ -25,6 +25,7 @@ The plugin also supports the following:
|
`tkss`
| tmux kill-session -t | Terminate named running tmux session |
|
`tkss`
| tmux kill-session -t | Terminate named running tmux session |
|
`tmux`
|
`_zsh_tmux_plugin_run`
| Start a new tmux session |
|
`tmux`
|
`_zsh_tmux_plugin_run`
| Start a new tmux session |
|
`tmuxconf`
|
`$EDITOR $ZSH_TMUX_CONFIG`
| Open .tmux.conf file with an editor |
|
`tmuxconf`
|
`$EDITOR $ZSH_TMUX_CONFIG`
| Open .tmux.conf file with an editor |
|
`tds`
|
`_tmux_directory_session`
| Creates or attaches to a session for the current path |
## Configuration Variables
## Configuration Variables
...
...
plugins/tmux/tmux.plugin.zsh
View file @
104041a0
...
@@ -108,6 +108,19 @@ compdef _tmux _zsh_tmux_plugin_run
...
@@ -108,6 +108,19 @@ compdef _tmux _zsh_tmux_plugin_run
# Alias tmux to our wrapper function.
# Alias tmux to our wrapper function.
alias
tmux
=
_zsh_tmux_plugin_run
alias
tmux
=
_zsh_tmux_plugin_run
function
_tmux_directory_session
()
{
# current directory without leading path
local dir
=
${
PWD
##*/
}
# md5 hash for the full working directory path
local
md5
=
$(
printf
'%s'
"
$PWD
"
|
md5sum
|
cut
-d
' '
-f
1
)
# human friendly unique session name for this directory
local
session_name
=
"
${
dir
}
-
${
md5
:0:6
}
"
# create or attach to the session
tmux new
-As
"
$session_name
"
}
alias
tds
=
_tmux_directory_session
# Autostart if not already in tmux and enabled.
# Autostart if not already in tmux and enabled.
if
[[
-z
"
$TMUX
"
&&
"
$ZSH_TMUX_AUTOSTART
"
==
"true"
&&
-z
"
$INSIDE_EMACS
"
&&
-z
"
$EMACS
"
&&
-z
"
$VIM
"
&&
-z
"
$INTELLIJ_ENVIRONMENT_READER
"
]]
;
then
if
[[
-z
"
$TMUX
"
&&
"
$ZSH_TMUX_AUTOSTART
"
==
"true"
&&
-z
"
$INSIDE_EMACS
"
&&
-z
"
$EMACS
"
&&
-z
"
$VIM
"
&&
-z
"
$INTELLIJ_ENVIRONMENT_READER
"
]]
;
then
# Actually don't autostart if we already did and multiple autostarts are disabled.
# Actually don't autostart if we already did and multiple autostarts are disabled.
...
...
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