My development environment tends to consist of a set of terminal windows and a text editor (currently Sublime Text). Rather right clicking on each terminal tab to give it a name I wanted to set it from the command line.
That way I can open new tabs with Ctl-+, and then keep them organized. By placing the following script in /usr/local/bin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#******************************************************************************** | |
# Copyright 2014 IBM | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
#******************************************************************************** | |
# Sets name of the maxOS terminal | |
usage() | |
{ | |
echo "Usage: `basename $0` nameOfWindow" | |
echo "" | |
echo "Sets the name of the terminal window on your mac" | |
echo "" | |
} | |
if [ "$#" == "1" ]; then | |
echo "setting name of tab to $1" | |
echo -n -e "\033]0;$1\007" | |
else | |
echo "incorrect arguments" | |
usage | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Robbie-2014-MacBook-Pro:foo robbie$ git clone https://gist.github.com/d3bc496f01f6221ec0a1.git | |
Cloning into 'd3bc496f01f6221ec0a1'... | |
remote: Counting objects: 3, done. | |
remote: Compressing objects: 100% (2/2), done. | |
remote: Total 3 (delta 0), reused 0 (delta 0) | |
Unpacking objects: 100% (3/3), done. | |
Checking connectivity... done. | |
Robbie-2014-MacBook-Pro:foo robbie$ ls | |
d3bc496f01f6221ec0a1 | |
Robbie-2014-MacBook-Pro:foo robbie$ cd d3bc496f01f6221ec0a1/ | |
Robbie-2014-MacBook-Pro:d3bc496f01f6221ec0a1 robbie$ sudo cp setName.sh /usr/local/bin/title | |
Password: | |
Robbie-2014-MacBook-Pro:d3bc496f01f6221ec0a1 robbie$ sudo chmod +x /usr/local/bin/title | |
Password: | |
Robbie-2014-MacBook-Pro:d3bc496f01f6221ec0a1 robbie$ title foo | |
setting name of tab to foo |
For some other useful tips on using terminal such as setting the theme on the command line check out:
- https://gigaom.com/2009/03/26/terminal-tips-using-the-command-line-with-style
- http://superuser.com/questions/187591/os-x-terminal-command-to-change-color-themes
No comments:
Post a Comment