Fast and easily changeable shortcuts to run Linux shell commands
- Set and manage shortcuts to run Linux shell commands
- Speed in running, setting, and removing shortcuts
- set:
s -a t name-of-long-command
- run:
s t
will runname-of-long-command
- remove:
s -rm t
- set:
- Ability to pass arguments and use functions
- Advantages over alias:
- Set and remove shortcuts quickly (no need to edit .bashrc)
- No name collisions
- Save and use instantly in all terminal sessions
- Clone repository
- Enter the folder "install" and run
sudo ./install-sc
.
- Open a new terminal and type
s -h
. You should get some usage output. - Run
s -a hw echo hello world
. This sets the shortcut with token hw. - Run
s hw
. You should see hello world being echoed. - Run
s
. The program wil print a list of valid commands (there should be only one so far). - Run
s -rm hw
to remove the command to print hello world.
- Pipes
s -a ll "ls | less"
s ll
executesls
and then pipes the output toless
- Command arguments
s -a lg "ls | grep"
s lg -i desktop
searches for files matching the pattern "desktop" ignoring case
- Use previous command
echo hello
s -a e !!
sets shortcut "e" to the previous commands e
should echo hello
- Save directory
- Go into any directory
s -a d1 cd $(pwd)
will create a shortcut that will enter the current directory- Go into a different directory
s d1
will bring you back to the original directory
- Functions
s -a a2f 'f(){ cat $1>>$2;}; f'
creates a function that will append the content of one file to anotherecho hello > a.txt
echo world > b.txt
s a2f b.txt a.txt
the contents ofa.txt
will be appended tob.txt
cat b.txt
should now output hello world (with a newline in between)
s
- List all possible commands
s -h
- Show usage
s <name> [<args>]
- Run command with specified name
- Any arguments are passed to the command
s -a <token> <command> [<args>]
- Add new command with name token
- New token name can be comprised of any alphanumeric sequence (excluding
-h
,-a
,-rm-
, spaces, and other bash reserved characters)
s -rm <name>
- Remove command with specified name