我正在编写以下功能:
override func viewDidAppear(_ animated: Bool) {
// I have did sample for you by taking .pdf from bundle.
if let pathPDF = Bundle.main.path(forResource: "sample", ofType: "pdf") {
let path = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)
let documentDirectoryPath:String = path[0]
let fileManager = FileManager()
var destinationURLForFile = URL(fileURLWithPath: documentDirectoryPath.appending("/NewFileiCloud"))
do {
//You have to create directory with above name.
try fileManager.createDirectory(at: destinationURLForFile, withIntermediateDirectories: true, attributes: nil)
destinationURLForFile.appendPathComponent("reader.pdf")
//YOUR PDF URL [pathPDF [my bundle path, you have to give your URL]] to DATA
let pdfData = try Data(contentsOf: URL(fileURLWithPath: pathPDF))
// WRITE ITS CONTENT to Doc.Dir.
try pdfData.write(to: destinationURLForFile, options:.atomic)
//ASSIGN PATH TO GLOBAL URL VARIABLE
fullPAth = destinationURLForFile
print("conclude ", destinationURLForFile)
uploadToServer()
}
catch(let error){
print(error)
}
}
}
func uploadToServer() {
.....
do {
// Here you can get PDF contents as Data.
// With this Data, you can pass to Server Side.
let pdfPOSTData = try Data(contentsOf: fullPAth!)
}
catch let e{
print("Catch_Not_worlk ", e)
}
......
}
这样做的目的是将tmux() {
if [ "$1" = "menu" ]; then
if [ ! -n "$TMUX" ] && [[ $(tmux ls | head -n 1) == *"created"* ]]; then
selection=$(tmux ls | fzf -m | cut -f 1 -d " ")
tmux attach -t ${selection: : -1}
fi
else
command tmux $@
fi
}
用管道传输到tmux ls
中,以生成用于选择tmux会话的菜单。
这很好用,但是如果我不想选择任何东西,然后按fzf
,它将返回:
CTRL-C
到底有没有抑制它或阻止它打印在第一位?