mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Allow $HOME as default-path in tmux.conf so the same config file can be used
on different machines regardless of where the user's home directory is. ok nicm
This commit is contained in:
		
							
								
								
									
										7
									
								
								cmd.c
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								cmd.c
									
									
									
									
									
								
							@@ -1221,11 +1221,18 @@ cmd_get_default_path(struct cmd_ctx *ctx)
 | 
			
		||||
	char			*cwd;
 | 
			
		||||
	struct session		*s;
 | 
			
		||||
	struct window_pane	*wp;
 | 
			
		||||
	struct environ_entry	*envent;
 | 
			
		||||
 | 
			
		||||
	if ((s = cmd_current_session(ctx, 0)) == NULL)
 | 
			
		||||
		return (NULL);
 | 
			
		||||
 | 
			
		||||
	cwd = options_get_string(&s->options, "default-path");
 | 
			
		||||
	if ((cwd[0] == '~' && cwd[1] == '\0') || !strcmp(cwd, "$HOME")) {
 | 
			
		||||
		envent = environ_find(&global_environ, "HOME");
 | 
			
		||||
		if (envent != NULL && *envent->value != '\0')
 | 
			
		||||
			return envent->value;
 | 
			
		||||
		cwd = "";
 | 
			
		||||
	}
 | 
			
		||||
	if (*cwd == '\0') {
 | 
			
		||||
		if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
 | 
			
		||||
			return (ctx->cmdclient->cwd);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user