Skip to content

Instantly share code, notes, and snippets.

@Ajedi32
Created May 1, 2013 16:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ajedi32/5496276 to your computer and use it in GitHub Desktop.
Save Ajedi32/5496276 to your computer and use it in GitHub Desktop.
Add this to your `~/.bashrc` file to enable the use of the `subl` command on your Git Bash prompt on Windows. (It may work with other shells as well, but I've only tested this with Git Bash on Windows and bash on Ubuntu.) Note that this command not only supports file input, but also simulates support for piped input as well. ``` Usage: subl file…
# Enable the use of the `subl` command
subl () {
subl_path='C:\Program Files\Sublime Text 2\sublime_text.exe'
if test -t 0
then
"$subl_path" $*
else
timestamp=`date +%s`
filename=$1
shift
if [ -z $filename ]; then filename=".temp$timestamp" ; fi
touch "$filename"
while read data
do
echo "$data" >> "$filename"
done
"$subl_path" "$filename" $*
sleep 1
rm "$filename"
fi
}
@Rio517
Copy link

Rio517 commented Aug 7, 2013

Thanks for sharing! This worked well for piping output to Sublime Text on Linux Mint command line. I only had to change the executable path to subl_path='sublime-text', and wola! I can do git diff /path/to/file | subl.

@tycooon
Copy link

tycooon commented Oct 10, 2013

Thanks for sharing, works well on my Ubuntu.

@zzFluke
Copy link

zzFluke commented Jul 18, 2014

Thanks much! Works like a charm on Win7+MinGW/MSYS. Just set subl_path='sublime_text' along with Sublime Text install dir. in PATH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment