Skip to content

Instantly share code, notes, and snippets.

@drewthorp
drewthorp / tab.fish
Last active June 1, 2018 07:11
Fish shell function to open a new tab in OS X terminal and run a series of commands. Usage tab cmd1 cmd2....
function tab
set -l ascmd "osascript -e 'tell application \"Terminal\" to activate' -e 'tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down'"
for arg in $argv
set ascmd "$ascmd -e 'tell application \"Terminal\" to do script \"$arg\" in selected tab of the front window'"
end
set -l ascmd "$ascmd;"
eval $ascmd
end
@drewthorp
drewthorp / fs_runscript.fish
Created November 3, 2014 13:15
Fish shell function that runs either a script or set of commands upon entering a directory. This function requires my change of directory event (https://gist.github.com/drewthorp/d8e5d888be72244b8d8a), and as with as event capturing function (It seems) cannot be autoloading. The script .fs_script will be executed upon entering its containing dir…
function fs_runscript -e directory_changed
if test -f "./.fs_script"
eval ("./.fs_script")
end
if test -f "./.fs_cmd"
# read file and run contents
set -l fs_cmd (cat ./.fs_cmd)
eval $fs_cmd
end
end
@drewthorp
drewthorp / fs_change_directory.fish
Last active August 29, 2015 14:08
A fish shell function that emits an event when the current directory changes. As of version 2.1.1, function that capture events do not seem to work as autoloading functions, so the easiest thing is to place this in config.fish. As this uses the fish_prompt event, the change of directory will only be notes when a prompt is displayed. It would be …
set -xg FS_CURRENT_DIR ""
function fs_change_directory -e fish_prompt
set -l this_dir (PWD)
if [ $this_dir != $FS_CURRENT_DIR ]
set -xg FS_CURRENT_DIR (pwd)
emit directory_changed
end
end
@drewthorp
drewthorp / gfpush.sh
Created February 6, 2012 17:18
Git flow develop publish script
#!/bin/bash
echo "Merging the develop branch with the master branch and pushing to the remote repository..."
git checkout master
git fetch origin master
git merge --no-ff develop
git push origin master
git checkout develop
git fetch origin develop