mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-03 16:46:18 +00:00 
			
		
		
		
	Restore pane_current_path format from portable tmux, it is no longer
used by default and is very useful.
This commit is contained in:
		
							
								
								
									
										16
									
								
								format.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								format.c
									
									
									
									
									
								
							@@ -741,6 +741,21 @@ format_cb_current_command(struct format_tree *ft, struct format_entry *fe)
 | 
				
			|||||||
	free(cmd);
 | 
						free(cmd);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Callback for pane_current_path. */
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					format_cb_current_path(struct format_tree *ft, struct format_entry *fe)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct window_pane	*wp = ft->wp;
 | 
				
			||||||
 | 
						char			*cwd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (wp == NULL)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cwd = get_proc_cwd(wp->fd);
 | 
				
			||||||
 | 
						if (cwd != NULL)
 | 
				
			||||||
 | 
							fe->value = xstrdup(cwd);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Callback for history_bytes. */
 | 
					/* Callback for history_bytes. */
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
format_cb_history_bytes(struct format_tree *ft, struct format_entry *fe)
 | 
					format_cb_history_bytes(struct format_tree *ft, struct format_entry *fe)
 | 
				
			||||||
@@ -2722,6 +2737,7 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
 | 
				
			|||||||
	format_add(ft, "pane_pid", "%ld", (long) wp->pid);
 | 
						format_add(ft, "pane_pid", "%ld", (long) wp->pid);
 | 
				
			||||||
	format_add_cb(ft, "pane_start_command", format_cb_start_command);
 | 
						format_add_cb(ft, "pane_start_command", format_cb_start_command);
 | 
				
			||||||
	format_add_cb(ft, "pane_current_command", format_cb_current_command);
 | 
						format_add_cb(ft, "pane_current_command", format_cb_current_command);
 | 
				
			||||||
 | 
						format_add_cb(ft, "pane_current_path", format_cb_current_path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	format_add(ft, "cursor_x", "%u", wp->base.cx);
 | 
						format_add(ft, "cursor_x", "%u", wp->base.cx);
 | 
				
			||||||
	format_add(ft, "cursor_y", "%u", wp->base.cy);
 | 
						format_add(ft, "cursor_y", "%u", wp->base.cy);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										15
									
								
								procname.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								procname.c
									
									
									
									
									
								
							@@ -38,6 +38,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static struct kinfo_proc *cmp_procs(struct kinfo_proc *, struct kinfo_proc *);
 | 
					static struct kinfo_proc *cmp_procs(struct kinfo_proc *, struct kinfo_proc *);
 | 
				
			||||||
char	*get_proc_name(int, char *);
 | 
					char	*get_proc_name(int, char *);
 | 
				
			||||||
 | 
					char	*get_proc_cwd(int);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct kinfo_proc *
 | 
					static struct kinfo_proc *
 | 
				
			||||||
cmp_procs(struct kinfo_proc *p1, struct kinfo_proc *p2)
 | 
					cmp_procs(struct kinfo_proc *p1, struct kinfo_proc *p2)
 | 
				
			||||||
@@ -132,3 +133,17 @@ error:
 | 
				
			|||||||
	free(buf);
 | 
						free(buf);
 | 
				
			||||||
	return (NULL);
 | 
						return (NULL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					char *
 | 
				
			||||||
 | 
					get_proc_cwd(int fd)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					        int             name[] = { CTL_KERN, KERN_PROC_CWD, 0 };
 | 
				
			||||||
 | 
					        static char     path[MAXPATHLEN];
 | 
				
			||||||
 | 
					        size_t          pathlen = sizeof path;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ((name[2] = tcgetpgrp(fd)) == -1)
 | 
				
			||||||
 | 
					                return (NULL);
 | 
				
			||||||
 | 
					        if (sysctl(name, 3, path, &pathlen, NULL, 0) != 0)
 | 
				
			||||||
 | 
					                return (NULL);
 | 
				
			||||||
 | 
					        return (path);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								tmux.1
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								tmux.1
									
									
									
									
									
								
							@@ -4409,6 +4409,7 @@ The following variables are available, where appropriate:
 | 
				
			|||||||
.It Li "pane_at_top" Ta "" Ta "1 if pane is at the top of window"
 | 
					.It Li "pane_at_top" Ta "" Ta "1 if pane is at the top of window"
 | 
				
			||||||
.It Li "pane_bottom" Ta "" Ta "Bottom of pane"
 | 
					.It Li "pane_bottom" Ta "" Ta "Bottom of pane"
 | 
				
			||||||
.It Li "pane_current_command" Ta "" Ta "Current command if available"
 | 
					.It Li "pane_current_command" Ta "" Ta "Current command if available"
 | 
				
			||||||
 | 
					.It Li "pane_current_path" Ta "" Ta "Current path if available"
 | 
				
			||||||
.It Li "pane_dead" Ta "" Ta "1 if pane is dead"
 | 
					.It Li "pane_dead" Ta "" Ta "1 if pane is dead"
 | 
				
			||||||
.It Li "pane_dead_status" Ta "" Ta "Exit status of process in dead pane"
 | 
					.It Li "pane_dead_status" Ta "" Ta "Exit status of process in dead pane"
 | 
				
			||||||
.It Li "pane_format" Ta "" Ta "1 if format is for a pane"
 | 
					.It Li "pane_format" Ta "" Ta "1 if format is for a pane"
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								tmux.h
									
									
									
									
									
								
							@@ -2743,6 +2743,7 @@ int		 utf8_cstrhas(const char *, const struct utf8_data *);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* procname.c */
 | 
					/* procname.c */
 | 
				
			||||||
char   *get_proc_name(int, char *);
 | 
					char   *get_proc_name(int, char *);
 | 
				
			||||||
 | 
					char   *get_proc_cwd(int);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* log.c */
 | 
					/* log.c */
 | 
				
			||||||
void	log_add_level(void);
 | 
					void	log_add_level(void);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user