Add iterm_set_font script to bin/
This commit is contained in:
		
							parent
							
								
									18940fe091
								
							
						
					
					
						commit
						6f1d8b4ecb
					
				
					 1 changed files with 34 additions and 0 deletions
				
			
		
							
								
								
									
										34
									
								
								bin/iterm_set_font.py
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										34
									
								
								bin/iterm_set_font.py
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,34 @@ | |||
| #!/usr/bin/env python3 | ||||
| # Eryn Wells <eryn@erynwells.me> | ||||
| 
 | ||||
| import argparse | ||||
| import iterm2 | ||||
| 
 | ||||
| def parse_args(argv, *a, **kw): | ||||
|     parser = argparse.ArgumentParser(*a, **kw) | ||||
|     parser.add_argument('font') | ||||
|     args = parser.parse_args(argv) | ||||
|     return args | ||||
| 
 | ||||
| def main(argv): | ||||
|     args = parse_args(argv[1:], prog=argv[0]) | ||||
| 
 | ||||
|     new_font = args.font | ||||
|     print(f'Will attempt to set font to "{new_font}"') | ||||
| 
 | ||||
|     async def set_font(connection): | ||||
|         profile = await iterm2.Profile.async_get_default(connection) | ||||
|         if not profile: | ||||
|             return | ||||
| 
 | ||||
|         print(f'Current normal font of "{profile.name}" profile is "{profile.normal_font}"') | ||||
|         print(f'Setting normal font of "{profile.name}" profile to "{new_font}"') | ||||
| 
 | ||||
|         await profile.async_set_normal_font(new_font) | ||||
| 
 | ||||
|     iterm2.run_until_complete(set_font) | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     import sys | ||||
|     result = main(sys.argv) | ||||
|     sys.exit(0 if not result else result) | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue