Skip to content

Commit

Permalink
Adding Hotkey Memory locations
Browse files Browse the repository at this point in the history
  • Loading branch information
raguay committed Jun 22, 2017
1 parent 85ed278 commit 14a297b
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 48 deletions.
10 changes: 9 additions & 1 deletion Key Bindings.json
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
[
{ "keys": ["Shift+f"], "command": "set_favorite_directory" },
{ "keys": ["Ctrl+f"], "command": "remove_favorite_directory"},
{ "keys": ["Ctrl+0"], "command": "go_to_favorite"}
{ "keys": ["Ctrl+0"], "command": "go_to_favorite"},
{ "keys": ["Cmd+1"], "command": "set_hot_dir1"},
{ "keys": ["Cmd+2"], "command": "set_hot_dir2"},
{ "keys": ["Cmd+3"], "command": "set_hot_dir3"},
{ "keys": ["Cmd+4"], "command": "set_hot_dir4"},
{ "keys": ["Alt+1"], "command": "go_to_hot_dir1"},
{ "keys": ["Alt+2"], "command": "go_to_hot_dir2"},
{ "keys": ["Alt+3"], "command": "go_to_hot_dir3"},
{ "keys": ["Alt+4"], "command": "go_to_hot_dir4"}
]
Empty file modified LICENSE
100755 → 100644
Empty file.
127 changes: 81 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,81 @@
## Favorites

Plugin for [fman.io](https://fman.io) that gives you the ability to setup a list of favorite directories to go to.

Install by uploading "Favorites" to your [data directory](https://fman.io/docs/customizing-fman)`/Plugins/ThirdParty`.

After restarting **fman**, you will have the ability to set favorite directories, go to them, set path shorteners, remove path shorteners, and remove favorites.

### Usage

#### HotKeys Set

<Shift+f> - Set a new Favorite directory

<Ctrl+f> - Remove a Favorite Directory.

<Ctrl+0> - Go to a Favorite Directory.

#### Commands

`Go To Favorite` - This command will display a list of favorites by their assigned names for the user to choose from. As you type letters in the name, the list is shortened. Once one is selected, the current panel is moved to that directory.

`Remove Favorite Directory` - This command will remove the selected favorite directory.

`Set Favorite Directory` - This command sets the currently highlighted directory as a favorite. If the path contains a shortener's path, then it will be shortened to that shorener's name in double brackets.

`Set Shorten Directory` - This command asks the user for a shortener name and creates a new shortener to that directory.

`Remove Shortener Directory` - This command removes a shortener directory from the shortener list. It then expands the shortener in all the favorites that had that shortener.

#### Files Created and Used

`~/.favoritedirs` - This file contains all of your favorite directories. Each line is the assigned name, a "|" symbol, and the path to the directory. If the path contains a directory in the `~/.shorenerdirs` file, then the path is removed and a placeholder is inserted instead.

`~/.shortenerdirs` - This file contains all the shortener directories and their names. It is in the same format as the `~/.favoritedirs` file. Once you create this file, copy it to your Dropbox location and link it back to this location. Now you can share your favorites between systems.

#### Suggested Usage

Once you install the plugin, set up your shortener directories. I setup one for each of my Dropbox locations. Then, create your favorites in the shorteners subdirectories. Once you have the favorites setup, move your `~/.favoritedirs` to your Dropbox location you want and link to the original location and name. On the second system, setup the same shortener file using the same names and link the synced favoritedirs file to the normal location. Now you can go to the favorite directories inside these shortener directories easily! They also automatically update when you add new ones.

### Features

- The ability to set a favorite directory.
- The ability to go to a favorite directory.
- Remove a favorite directory.
- Set up directories as shorteners with a name. Then all paths under that directory will be set to the shortener's name and expanded to that path when going to it. This gives the ability to share favorites between system just using the paths in common.
## Favorites

Plugin for [fman.io](https://fman.io) that gives you the ability to setup a list of favorite directories to go to.

You can install this plugin by pressing `<shift+cmd+p>` to open the command pallet. Then type `install plugin`. Look for the `favorite` plugin and select it.

After restarting **fman**, you will have the ability to set favorite directories, go to them, set path shorteners, remove path shorteners, remove favorites, and set/go to four directory locations kept in memory.

### Usage

#### HotKeys Set

<Shift+f> - Set a new Favorite directory

<Ctrl+f> - Remove a Favorite Directory.

<Ctrl+0> - Go to a Favorite Directory.

<Cmd+1> - Set the first directory memory to the current panel's directory.

<Cmd+2> - Set the second directory memory to the current panel's directory.

<Cmd+3> - Set the third directory memory to the current panel's directory.

<Cmd+4> - Set the fourth directory memory to the current panel's directory.

<Alt+1> - Set the current panel to go to the first directory memory location.

<Alt+2> - Set the current panel to go to the second directory memory location.

<Alt+3> - Set the current panel to go to the third directory memory location.

<Alt+4> - Set the current panel to go to the fourth directory memory location.

#### Commands

`Go To Favaorite` - This command will display a list of favorites by their assigned names for the user to choose from. As you type letters in the name, the list is shortened. Once one is selected, the current panel is moved to that directory.

`Remove Favorite Directory` - This command will remove the selected favorite directory.

`Set Favorite Directory` - This command sets the currently highlighted directory as a favorite. If the path contains a shortener's path, then it will be shortened to that shorener's name in double brackets.

`Set Shorten Directory` - This command asks the user for a shortener name and creates a new shortener to that directory.

`Remove Shortener Directory` - This command removes a shortener directory from the shortener list. It then expands the shortener in all the favorites that had that shortener.

`Go to hot dir1` - This command set the current panel to the directory store in the memory location 1. The default is home.

`Go to hot dir2` - This command set the current panel to the directory store in the memory location 2. The default is home.

`Go to hot dir3` - This command set the current panel to the directory store in the memory location 3. The default is home.

`Go to hot dir4` - This command set the current panel to the directory store in the memory location 4. The default is home.

`Set hot dir1` - This command set the current panel to the directory store in the memory location 1. The default is home.

`Set hot dir2` - This command set the current panel to the directory store in the memory location 2. The default is home.

`Set hot dir3` - This command set the current panel to the directory store in the memory location 3. The default is home.

`Set hot dir4` - This command set the current panel to the directory store in the memory location 4. The default is home.

#### Files Created and Used

`~/.favoritedirs` - This file contains all of your favorite directories. Each line is the assigned name, a "|" symbol, and the path to the directory. If the path contains a directory in the `~/.shorenerdirs` file, then the path is removed and a placeholder is inserted instead.

`~/.shortenerdirs` - This file contains all the shortener directories and their names. It is in the same format as the `~/.favoritedirs` file. Once you create this file, copy it to your Dropbox location and link it back to this location. Now you can share your favorites between systems.

#### Suggested Usage

Once you install the plugin, set up your shortener directories. I setup one for each of my Dropbox locations. Then, create your favorites in the shorteners subdirectories. Once you have the favorites setup, move your `~/.favoritedirs` to your Dropbox location you want and link to the original location and name. On the second system, setup the same shortener file using the same names and link the synced favoritedirs file to the normal location. Now you can go to the favorite directories inside these shortener directories easily! They also automatically update when you add new ones.

You can also save and restore directory locations in the internal memory. There are four memory locations set aside to use. Very useful for saving a location, going somewhere else, and then popping right back to the previous location. These locations are lost when exiting fman.

### Features

- The ability to set a favorite directory.
- The ability to go to a favorite directory.
- Remove a favorite directory.
- Set up directories as shorteners with a name. Then all paths under that directory will be set to the shortener's name and expanded to that path when going to it. This gives the ability to share favorites between system just using the paths in common.
- There are four memory locations to set directory values that can be easily recalled as well. Store from any panel and restore to any panel.
108 changes: 107 additions & 1 deletion favorites/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
FAVORITELIST = os.path.expanduser("~") + "/.favoritedirs"
SHORTENERLIST = os.path.expanduser("~") + "/.shortenerdirs"

#
# The next global variable is for storing short term memory of directory locations. These
# Will be quickly jumped to with hotkeys. I doubt I'll ever need more than four.
#
HOTLIST = ["~","~","~","~"]

#
# Function: GoToFavaorite
#
Expand Down Expand Up @@ -288,4 +294,104 @@ def path_is_parent(parent_path, child_path):
child_path = os.path.abspath(child_path)

# Compare the common path of the parent and child path with the common path of just the parent path. Using the commonpath method on just the parent path will regularise the path name in the same way as the comparison that deals with both paths, removing any trailing path separator
return os.path.commonpath([parent_path]) == os.path.commonpath([parent_path, child_path])
return os.path.commonpath([parent_path]) == os.path.commonpath([parent_path, child_path])

#
# Function: goToHotDir
#
# Description: Go to the directory stored in the HOTLIST memory.
#
def goToHotDir(panel,dirNum):
if dirNum < 0 or dirNum >4:
dirNum = 0
panel.pane.set_path(expandDirPath(HOTLIST[dirNum]))

#
# Function: setHotDir
#
# Description: Set the current panel's directory into the specified HOTLIST memory.
#
def setHotDir(panel,dirNum):
if dirNum < 0 or dirNum >3:
dirNum = 0
HOTLIST[dirNum] = panel.pane.get_path()

#
# Function: SetHotDir1
#
# Description: This class performs the operation of going
# to the first directory stored in memory.
#
class SetHotDir1(DirectoryPaneCommand):
def __call__(self):
setHotDir(self,0)

#
# Function: SetHotDir2
#
# Description: This class performs the operation of going
# to the second directory stored in memory.
#
class SetHotDir2(DirectoryPaneCommand):
def __call__(self):
setHotDir(self,1)

#
# Function: SetHotDir3
#
# Description: This class performs the operation of going
# to the third directory stored in memory.
#
class SetHotDir3(DirectoryPaneCommand):
def __call__(self):
setHotDir(self,2)

#
# Function: SetHotDir4
#
# Description: This class performs the operation of going
# to the fourth directory stored in memory.
#
class SetHotDir4(DirectoryPaneCommand):
def __call__(self):
setHotDir(self,3)

#
# Function: GoToHotDir1
#
# Description: This class performs the operation of going
# to the first directory stored in memory.
#
class GoToHotDir1(DirectoryPaneCommand):
def __call__(self):
goToHotDir(self,0)

#
# Function: GoToHotDir2
#
# Description: This class performs the operation of going
# to the second directory stored in memory.
#
class GoToHotDir2(DirectoryPaneCommand):
def __call__(self):
goToHotDir(self,1)

#
# Function: GoToHotDir3
#
# Description: This class performs the operation of going
# to the third directory stored in memory.
#
class GoToHotDir3(DirectoryPaneCommand):
def __call__(self):
goToHotDir(self,2)

#
# Function: GoToHotDir4
#
# Description: This class performs the operation of going
# to the fourth directory stored in memory.
#
class GoToHotDir4(DirectoryPaneCommand):
def __call__(self):
goToHotDir(self,3)

0 comments on commit 14a297b

Please sign in to comment.