Skip to content

Instantly share code, notes, and snippets.

@Fity
Created August 19, 2014 16:27
Show Gist options
  • Save Fity/0ecb4117eb62198b1040 to your computer and use it in GitHub Desktop.
Save Fity/0ecb4117eb62198b1040 to your computer and use it in GitHub Desktop.
#!/bin/zsh
# with bugs, can not use $$, it is the current pid, use $PPID instead
function Usage() {
cat<<EOF
change the parameter orders of the last command and execute again
eg:
for commmand 'ls -l -a -h'
chargs 3 1 2
will execute 'ls -h -l -a'
EOF
}
function Main() {
local c_shell
c_shell=$(get_shell)
echo "current shell is *$c_shell*"
}
function get_shell {
ps -ef | grep $$ | grep -v grep | grep -v ps | awk '{print $8}' | grep -v awk
}
Main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment