Skip to content

Commit dd1256f

Browse files
committed
update source
1 parent 3fff344 commit dd1256f

File tree

5 files changed

+43
-23
lines changed

5 files changed

+43
-23
lines changed

README.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Script tiện ích cho macOS được xây dựng bằng **Hammerspoon + Lua**.
44

55
- 📋 Clipboard Manager (Hiển thị lịch sử những từ được sao chép)
66
- 🪄 Paste name branch in field filter Sourcetree (Dán đuôi của branch - phù hợp với chức năng filter ở Sourcetree)
7-
- 💻 Open current folder in Terminal (Mở folder đang hiển thị ở Finder với Terminal)
7+
- 💻 Open current folder in Terminal (Mở Terminal với đường dẫn hiện tại ở Finder)
88

99
---
1010

@@ -24,9 +24,9 @@ Script tiện ích cho macOS được xây dựng bằng **Hammerspoon + Lua**.
2424
brew install --cask hammerspoon && brew install letienndat/hstools/utilities-macos
2525
```
2626

27-
#### Chỉ định version (ví dụ: 1.1.3)
27+
#### Chỉ định version (ví dụ: 1.1.4)
2828
```bash
29-
brew install --cask hammerspoon && brew install letienndat/hstools/[email protected].3
29+
brew install --cask hammerspoon && brew install letienndat/hstools/[email protected].4
3030
```
3131

3232
Nó cần cài: hammerspoon (bắt buộc, nếu thiết bị của bạn đã cài thì nó tự động bỏ qua không cài nữa, vì chương trình của tôi chạy trên môi trường hammerspoon)
@@ -37,9 +37,9 @@ Nó cần cài: hammerspoon (bắt buộc, nếu thiết bị của bạn đã c
3737
bash $(brew --cellar utilities-macos)/$(brew list --versions utilities-macos | awk '{print $2}')/install.sh
3838
```
3939

40-
#### Chỉ định version (ví dụ: 1.1.3)
40+
#### Chỉ định version (ví dụ: 1.1.4)
4141
```bash
42-
bash $(brew --cellar [email protected].3)/1.1.3/install.sh
42+
bash $(brew --cellar [email protected].4)/1.1.4/install.sh
4343
```
4444

4545
Chạy script install.sh để copy script `.lua` thù folder mặc định brew pull về sang folder `~/.hammerspoon` của Hammerspoon
@@ -98,7 +98,7 @@ feature = {
9898
| ----------------- | --------------------------------------------------------------------------------- |
9999
| `Cmd + Shift + C` | Mở menu clipboard history và dán mục đã chọn |
100100
| `Cmd + Shift + V` | Dán phần cuối của nhánh Git (phù hợp với filter branch Sourcetree) |
101-
| `Cmd + Shift + T` | Mở Terminal với thư mục đang được mở ở Finder |
101+
| `Cmd + Shift + T` | Mở Terminal với đường dẫn hiện tại ở Finder |
102102

103103
> Có thể xây dựng tính năng mới và gán hotkey tuỳ chỉnh của riêng bạn
104104
@@ -113,9 +113,9 @@ brew uninstall --cask hammerspoon && brew uninstall letienndat/hstools/utilities
113113
brew untap letienndat/hstools
114114
```
115115

116-
#### Chỉ định version (ví dụ 1.1.3)
116+
#### Chỉ định version (ví dụ 1.1.4)
117117
```bash
118-
brew uninstall --cask hammerspoon && brew uninstall letienndat/hstools/[email protected].3
118+
brew uninstall --cask hammerspoon && brew uninstall letienndat/hstools/[email protected].4
119119
brew untap letienndat/hstools
120120
```
121121

@@ -127,14 +127,6 @@ brew untap letienndat/hstools
127127

128128
---
129129

130-
## 🧑‍💻 Tác giả
131-
132-
[Le Tien Dat](https://github.com/letienndat)
133-
134-
---
135-
136130
## 📜 License
137131

138-
[MIT License.](https://github.com/letienndat/utilities-macos?tab=MIT-1-ov-file#)
139-
140-
## 🫶 Thanks for reading
132+
[MIT License.](https://github.com/letienndat/utilities-macos?tab=MIT-1-ov-file#)

assets/preview.png

5.54 KB
Loading

features.lua

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ local features = {
1515
},
1616
open_terminal = {
1717
title = "Open Current Folder With Terminal",
18-
description = "Mở thư mục hiện tại ở Finder với Terminal",
18+
description = "Mở Terminal với đường dẫn hiện tại ở Finder",
1919
hotkey = "Cmd + Shift + T",
2020
enabled = true,
2121
module = "features.open-terminal"
@@ -64,8 +64,29 @@ local function getFeatureList()
6464
return features
6565
end
6666

67+
local function trimToNumberLines(text, numberLines)
68+
text = tostring(text or "")
69+
numberLines = numberLines or 5
70+
local lines = {}
71+
for line in text:gmatch("[^\n]+") do
72+
table.insert(lines, line)
73+
end
74+
75+
if #lines > numberLines then
76+
local trimmed = {}
77+
for i = 1, numberLines do
78+
table.insert(trimmed, lines[i])
79+
end
80+
trimmed[numberLines] = trimmed[numberLines] .. ""
81+
return table.concat(trimmed, "\n")
82+
else
83+
return text
84+
end
85+
end
86+
6787
return {
6888
toggleFeature = toggleFeature,
6989
getFeatureList = getFeatureList,
70-
initAll = initAll
90+
initAll = initAll,
91+
trimToNumberLines = trimToNumberLines
7192
}

features/clipboard-manager.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
--=============CLIPBOARD-MANAGER - SHOW LIST TEXT COPIED -- [CMD+SHIFT+C]===========================
33
--==================================================================================================
44

5+
local features = require("features")
6+
57
local M = {}
68

79
local clipboardHistory = {}
810
local maxHistorySize = 50
11+
local numberLinesSubText = 8
912

1013
local watcher = nil
1114
local hotkey = nil
@@ -45,6 +48,7 @@ function M.start()
4548
if #preview > 100 then
4649
preview = preview:sub(1, 100) .. ""
4750
end
51+
text = features.trimToNumberLines(text, numberLinesSubText)
4852
table.insert(choices, { text = preview, subText = text })
4953
end
5054

@@ -58,7 +62,7 @@ function M.start()
5862
end)
5963
end)
6064
:choices(choices)
61-
:placeholderText("Enter value to paste")
65+
:placeholderText("Search item copied")
6266
:searchSubText(true)
6367
:show()
6468
end)

features/help.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@ local M = {}
99
function M.show()
1010
local list = features.getFeatureList()
1111
local choices = {}
12+
local numberLinesSubText = 5
1213

1314
for key, info in pairs(list) do
14-
local status = info.enabled and "✅ Đang bật: " or "❌ Đã tắt: "
15+
local status = string.format("%s [%s] %s", info.enabled and "" or "", info.hotkey, info.enabled and "Đang bật" or "Đã tắt")
16+
local subTextFormatted = features.trimToNumberLines(info.description, numberLinesSubText)
17+
1518
table.insert(
1619
choices,
1720
{
1821
title = info.title,
19-
text = string.format("%s %s [%s]", status, info.title, info.hotkey),
20-
subText = "\n" .. info.description,
22+
text = string.format("%s: %s", status, info.title),
23+
subText = "\n" .. subTextFormatted,
2124
uuid = key
2225
}
2326
)

0 commit comments

Comments
 (0)