Skip to content

Commit

Permalink
Make AeroSpace version and hash copyable
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitabobko committed Oct 24, 2023
1 parent 63fc400 commit a263e1c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/AeroSpaceApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ struct AeroSpaceApp: App {

var body: some Scene {
MenuBarExtra {
Text("\(Bundle.appName) v\(Bundle.appVersion) \(gitShortHash)")
let shortIdentification = "\(Bundle.appName) v\(Bundle.appVersion) \(gitShortHash)"
let identification = "\(Bundle.appName) v\(Bundle.appVersion) \(gitHash)"
Text(shortIdentification)
Button("Copy to clipboard") { identification.copyToClipboard() }
Divider()
Text("Workspaces:")
ForEach(Workspace.all) { (workspace: Workspace) in
Expand Down
6 changes: 6 additions & 0 deletions src/util/util.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ extension String {
func removePrefix(_ prefix: String) -> String {
hasPrefix(prefix) ? String(dropFirst(prefix.count)) : self
}

func copyToClipboard() {
let pasteboard = NSPasteboard.general
pasteboard.declareTypes([.string], owner: nil)
pasteboard.setString(self, forType: .string)
}
}

extension Double {
Expand Down

0 comments on commit a263e1c

Please sign in to comment.