A shepherd for your Appimages.
0

Configure Feed

Select the types of activity you want to include in your feed.

add link ocmmand for adding to PATH

Aly Raffauf (Jun 18, 2026, 11:47 AM EDT) 6625f361 ef7564a1

+197
+35
cmd/appherder/cli.go
··· 27 27 newInstallCommand(a), 28 28 newUninstallCommand(a), 29 29 newListCommand(a), 30 + newLinkCommand(a), 31 + newUnlinkCommand(a), 30 32 newSyncCommand(a), 31 33 newMigrateCommand(a), 32 34 newUpgradeCommand(a), ··· 213 215 } 214 216 cmd.Flags().BoolVar(&off, "off", false, offHelp) 215 217 return cmd 218 + } 219 + 220 + func newLinkCommand(a appherder.App) *cobra.Command { 221 + return &cobra.Command{ 222 + Use: "link APP", 223 + Short: "Add an installed AppImage to PATH", 224 + Long: "Creates a symlink in ~/.local/bin so the AppImage can be invoked by its name\n" + 225 + "from a terminal. The app must already be installed in ~/AppImages.", 226 + Args: cobra.ExactArgs(1), 227 + RunE: func(cmd *cobra.Command, args []string) error { 228 + if err := a.Link(args[0]); err != nil { 229 + return err 230 + } 231 + fmt.Fprintf(cmd.OutOrStdout(), "linked %s\n", appherder.NormalizeAppName(args[0])) 232 + return nil 233 + }, 234 + } 235 + } 236 + 237 + func newUnlinkCommand(a appherder.App) *cobra.Command { 238 + return &cobra.Command{ 239 + Use: "unlink APP", 240 + Short: "Remove an AppImage symlink from PATH", 241 + Long: "Removes the ~/.local/bin symlink created by `appherder link`.", 242 + Args: cobra.ExactArgs(1), 243 + RunE: func(cmd *cobra.Command, args []string) error { 244 + if err := a.Unlink(args[0]); err != nil { 245 + return err 246 + } 247 + fmt.Fprintf(cmd.OutOrStdout(), "unlinked %s\n", appherder.NormalizeAppName(args[0])) 248 + return nil 249 + }, 250 + } 216 251 } 217 252 218 253 func newAutosyncCommand() *cobra.Command {
+48
internal/appherder/link.go
··· 1 + package appherder 2 + 3 + import ( 4 + "fmt" 5 + "os" 6 + "path/filepath" 7 + ) 8 + 9 + func (a App) localBinDir() string { 10 + return filepath.Join(filepath.Dir(filepath.Dir(a.applicationsDir)), "bin") 11 + } 12 + 13 + func (a App) linkPath(appName string) string { 14 + return filepath.Join(a.localBinDir(), appName) 15 + } 16 + 17 + func (a App) appImagePath(appName string) string { 18 + return filepath.Join(a.appimagesDir, appName+".appimage") 19 + } 20 + 21 + func (a App) Link(appName string) error { 22 + appName = NormalizeAppName(appName) 23 + src := a.appImagePath(appName) 24 + if _, err := os.Stat(src); err != nil { 25 + return fmt.Errorf("%s is not installed", appName) 26 + } 27 + binDir := a.localBinDir() 28 + if err := os.MkdirAll(binDir, 0o755); err != nil { 29 + return fmt.Errorf("create %s: %w", binDir, err) 30 + } 31 + dst := a.linkPath(appName) 32 + if err := os.Remove(dst); err != nil && !os.IsNotExist(err) { 33 + return fmt.Errorf("remove existing link %s: %w", dst, err) 34 + } 35 + if err := os.Symlink(src, dst); err != nil { 36 + return fmt.Errorf("link %s -> %s: %w", dst, src, err) 37 + } 38 + return nil 39 + } 40 + 41 + func (a App) Unlink(appName string) error { 42 + appName = NormalizeAppName(appName) 43 + dst := a.linkPath(appName) 44 + if err := os.Remove(dst); err != nil { 45 + return fmt.Errorf("remove link %s: %w", dst, err) 46 + } 47 + return nil 48 + }