Last active
September 10, 2020 22:43
-
-
Save alvin-milton/f2d7e8caa842ee1bf4932c8cfa01805f to your computer and use it in GitHub Desktop.
Revisions
-
alvin-milton revised this gist
Sep 10, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ How many times do you empty your trash? If you are like me, sometimes a lot, sometimes never. It really depends on how long you tend to keep certain files in your system. -
alvin-milton revised this gist
Sep 10, 2020 . 1 changed file with 33 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,38 +1,58 @@ # Fun w Hammerspoon How many times do you empty your trash? If you are like me, sometimes a lot sometimes never. It really depends on how long you tend to keep certain files in your system. I wanted to automate the emptying of the trash. I don't want to use the mouse each time because keyboard shortcuts tend to be quicker. So ultimately, I want to be able to use the keyboard and "map" to a command that does this. Sounds simple right? First step was to work out in terminal how to do this. Found out you'd type a command like this to get it done: `rm -rf ~/.Trash/*` I definitely don't want to type this every time in terminal. Thats multiple keystrokes - the antithesis of what I want to achieve, so I created an alias. In `~/.bash_profile` this line exists: `alias trash="rm -rf ~/.Trash/*` This is closer, it maps the word trash to the command for emptying the trash. While aliases are cool, this still requires me to be in the terminal. & I'm not always in the terminal. Enter [Hammerspoon](http://www.hammerspoon.org/). Feel free to check that out. In my Hammerspoon config, lives a little bit of Lua _which kinda looks like JS_ code that looks like this: ``` hs.hotkey.bind(hyper, 'E', function() hs.execute('trash', true) end) ``` `hyper` is a variable I set higher in the config that simulates pressing the keys `CMD + SHIFT + ALT + SHIFT` together. Do enough research on Hammerspoon, and you'd end up understanding why this type of thing is helpful. [Hint, it has something to do with keyboard automation](https://karabiner-elements.pqrs.org/). I use the Caps Lock key to simulate pressing all those buttons. After reloading the config, I can now press CAPS LOCK + E to execute the terminal command `trash` but without being in the terminal & this will empty my trash. Mission achieved. -
alvin-milton revised this gist
Sep 10, 2020 . 1 changed file with 10 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,22 +1,29 @@ # Fun w Hammerspoon I wanted to automate emptying of the trash. I don't want to use the mouse each time. I want to be able to use the keyboard and map to a command that does this. Sounds simple right? In terminal, emptying the trash looks like this: `rm -rf ~/.Trash/*` I don't want to type this everytime in terminal, so I created an alias. `alias trash="rm -rf ~/.Trash/*` Aliases are cool but this still requires me to be in the terminal. I'm not always in the terminal. Enter hammerspoon. ``` hs.hotkey.bind(hyper, 'E', function() hs.execute('trash', true) end) ``` @@ -25,5 +32,7 @@ end) Google on how to set that up if you haven't done it already. So I'm binding to the letter E to be able to execute a terminal command. The terminal command being the alias to the terminal command. As long as my bash profile is in tact, simply press CAPS LOCK + E and empty my trash. -
alvin-milton created this gist
Sep 10, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ # Fun w Hammerspoon I wanted to automate emptying of the trash. I don't want to use the mouse each time. I want to be able to use the keyboard and map to a command that does this. Sounds simple right? In terminal, emptying the trash looks like this: `rm -rf ~/.Trash/*` I don't want to type this everytime in terminal, so I created an alias. `alias trash="rm -rf ~/.Trash/*` Aliases are cool but this still requires me to be in the terminal. I'm not always in the terminal. Enter hammerspoon. ```hs.hotkey.bind(hyper, 'E', function() hs.execute('trash', true) end) ``` `hyper` is a variable that simulates pressing CMD + SHIFT + ALT + SHIFT. Google on how to set that up if you haven't done it already. So I'm binding to the letter E to be able to execute a terminal command. The terminal command being the alias to the terminal command. As long as my bash profile is in tact, simply press CAPS LOCK + E and empty my trash.