Skip to content

Instantly share code, notes, and snippets.

@peteb
Created November 29, 2011 15:26
Show Gist options
  • Save peteb/1405164 to your computer and use it in GitHub Desktop.
Save peteb/1405164 to your computer and use it in GitHub Desktop.
Aliases for mkdir && cd. Quite common usage that is finally improved!
alias mkc "mkdir \!^ && cd \!^"
alias mkt 'cd `~/bin/mktest`'
#!/usr/bin/ruby
# creates a new directory called "test" + a running counter at the end. if test3 exists, create test4. if no test exists, create test1.
test_dir = (`ls -tr | grep test | tail -1` =~ /^test(.*)$/ \
&& "test" + ($1.to_i+1).to_s \
|| "test1")
`mkdir #{test_dir}`
puts test_dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment